- - - - - - - - + + + array('post', 'shuoshuo'), + 'post_status' => 'publish', + 's' => $search_query, + 'posts_per_page' => -1, + 'orderby' => 'relevance', + 'order' => 'DESC', + ); + + $all_results_query = new WP_Query($all_results_args); + + //结果 + $all_results = []; + $sticky_results = []; + $non_sticky_results = []; + + //分类置顶内容和非置顶内容 + if ($all_results_query->have_posts()) : + while ($all_results_query->have_posts()) : $all_results_query->the_post(); + if (in_array(get_the_ID(), $sticky_posts)) { + $sticky_results[] = $post; + } else { + $non_sticky_results[] = $post; + } + endwhile; + endif; + wp_reset_postdata(); + + //合并结果,优先展示置顶文章 + $all_results = array_merge($sticky_results, $non_sticky_results); + + // 内容分页 + $total_results = count($all_results); + $posts_per_page = 10; + $total_pages = ceil($total_results / $posts_per_page); + $current_page_results = array_slice($all_results, ($paged - 1) * $posts_per_page, $posts_per_page); + + //输出当前页内容 + if (!empty($current_page_results)) : + foreach ($current_page_results as $post) : + setup_postdata($post); + get_template_part('tpl/content', 'thumbcard'); + endforeach; + + //分页跳转 + the_posts_pagination(array( + 'total' => $total_pages, + 'current' => $paged, + )); + else : + //未找到搜索结果 + ?> + + + + - -
-
- - - - - -

-
- 0) : ?> - - - -
-
- -
- -
-
-
- - - ID, POST_METADATA_KEY, true); - $excerpt = has_excerpt(); - ?> -
-
- - - -
- - - -
- -

-
-
-
- -
- - -
- - -
-
- have_posts()) : + while ($non_sticky_query->have_posts()) : $non_sticky_query->the_post(); + get_template_part('tpl/content', 'thumbcard'); endwhile; endif; ?> \ No newline at end of file diff --git a/tpl/content-thumbcard.php b/tpl/content-thumbcard.php new file mode 100644 index 00000000..ec999cc1 --- /dev/null +++ b/tpl/content-thumbcard.php @@ -0,0 +1,192 @@ +">' + . __('Your browser does not support HTML5 video.', 'sakurairo') + . ''; + break; + case 'normal': + $video_cover = get_post_meta(get_the_ID(), 'video_cover', true); + $cover_html = ''; + break; + default: + $post_img = ''; + if (has_post_thumbnail()) { + $post_thumbnail_id = get_post_thumbnail_id($post->ID); + $large_image_url = wp_get_attachment_image_src($post_thumbnail_id, 'large'); + if ($large_image_url == false) { + $large_image_url = wp_get_attachment_image_src($post_thumbnail_id, 'medium'); + if ($large_image_url == false) { + $large_image_url = wp_get_attachment_image_src($post_thumbnail_id); + if ($large_image_url == false) { + $post_img = DEFAULT_FEATURE_IMAGE(); + } + } + } + $post_img = $large_image_url[0] ?? DEFAULT_FEATURE_IMAGE('th'); + } else { + $post_img = DEFAULT_FEATURE_IMAGE('th'); + } + $cover_html = 'post_img'; + break; + } + return $cover_html; + } +} + + // Determine post type + $post_type = get_post_type(); + if ($post_type == 'shuoshuo') { + // shuoshuo 样式 + $cover_html = get_post_cover_html(); + $emotion = get_post_meta(get_the_ID(), 'emotion', true); + if (empty($emotion)) { + $emotion = '\f86d'; // 默认值 + } + $emotion_color = get_post_meta(get_the_ID(), 'emotion_color', true); + if (empty($emotion_color)) { + $emotion_color = iro_opt('theme_skin_matching'); + } + $unique_id = 'shuoshuo-' . get_the_ID(); + ?> +
+
+
+ + + + +
+
+
+ + + + + +

+
+ 0) : ?> + + + +
+
+ +
+ +
+
+
+
+
+ ID, POST_METADATA_KEY, true); + $excerpt = has_excerpt(); + ?> +
+
+ + + +
+ + + +
+ +

+
+
+
+ +
+ + +
+ + +
+
+
ID, 'license', true); + $license = $post_meta_license ? $post_meta_license : iro_opt("article_lincenses"); $license_link; $license_icon; $license_desc; @@ -14,12 +16,12 @@ } if ($license === "cc0") { $license_link = "https://creativecommons.org/publicdomain/zero/1.0/"; - $license_desc = sprintf(__("This article is licensed under %s", "sakurairo"),"CC0 1.0"); + $license_desc = sprintf(__("This article is licensed under %s", "sakurairo"), "CC0 1.0"); $license_icon = array("fa-creative-commons-zero"); } else { $variant = substr($license, 3); $license_link = "https://creativecommons.org/licenses/$variant/4.0/"; - $license_desc = sprintf(__("This article is licensed under %s", "sakurairo"),"CC " . strtoupper($variant) . " 4.0"); + $license_desc = sprintf(__("This article is licensed under %s", "sakurairo"), "CC " . strtoupper($variant) . " 4.0"); $license_icon = array_map(function ($v) { return "fa-creative-commons-$v"; }, explode("-", $variant)); @@ -55,16 +57,16 @@
- -
- -
+
+ +