{"id":30717,"date":"2024-11-25T17:20:35","date_gmt":"2024-11-25T09:20:35","guid":{"rendered":"https:\/\/fwq.ai\/blog\/30717\/"},"modified":"2024-11-25T17:20:35","modified_gmt":"2024-11-25T09:20:35","slug":"wordpress%e5%88%86%e7%b1%bb%e4%b8%8e%e6%a0%87%e7%ad%be%e7%ad%89%e5%ad%98%e6%a1%a3%e9%a1%b5%e6%80%8e%e4%b9%88%e5%ae%9e%e7%8e%b0%e7%bd%ae%e9%a1%b6","status":"publish","type":"post","link":"https:\/\/fwq.ai\/blog\/30717\/","title":{"rendered":"WordPress\u5206\u7c7b\u4e0e\u6807\u7b7e\u7b49\u5b58\u6863\u9875\u600e\u4e48\u5b9e\u73b0\u7f6e\u9876"},"content":{"rendered":"<p style=\"text-align: center\"><strong><img decoding=\"async\" src=\"https:\/\/img.php.cn\/upload\/article\/000\/000\/020\/5e06b540700f7435.jpg\" class=\"aligncenter\" title=\"WordPress\u5206\u7c7b\u4e0e\u6807\u7b7e\u7b49\u5b58\u6863\u9875\u600e\u4e48\u5b9e\u73b0\u7f6e\u9876\u63d2\u56fe\" alt=\"WordPress\u5206\u7c7b\u4e0e\u6807\u7b7e\u7b49\u5b58\u6863\u9875\u600e\u4e48\u5b9e\u73b0\u7f6e\u9876\u63d2\u56fe\" \/><\/strong><\/p>\n<p><strong>\u5206\u7c7b\u4e0e\u6807\u7b7e\u7b49\u5b58\u6863\u9875\u600e\u4e48\u5b9e\u73b0\u7f6e\u9876\uff1f<\/strong><\/p>\n<p>\u672c\u6587\u5b9e\u4f8b\u8bb2\u8ff0\u4e86WordPress\u5206\u7c7b\u4e0e\u6807\u7b7e\u7b49\u5b58\u6863\u9875\u5b9e\u73b0\u7f6e\u9876\u7684\u65b9\u6cd5\u3002\u5206\u4eab\u7ed9\u5927\u5bb6\u4f9b\u5927\u5bb6\u53c2\u8003\u3002\u5177\u4f53\u5206\u6790\u5982\u4e0b\uff1a<\/p>\n<p>\u63a8\u8350\uff1a\u300a\u300b<\/p>\n<p>\u5728wordpress\u4e2d\u9ed8\u8ba4\u80fd\u7f6e\u9876\u6587\u7ae0\u5c31\u662f\u53ea\u6709\u9996\u9875\u4e86,\u5982\u679c\u6211\u4eec\u5e0c\u671b\u5206\u7c7b\/\u6807\u7b7e\u7b49\u5b58\u6863\u9875\u4e5f\u80fd\u7f6e\u9876\u6587\u7ae0\u6211\u4eec\u9700\u8981\u4e8c\u6b21\u5f00\u53d1.<\/p>\n<p>\u73b0\u5728\u53c2\u8003wp-includes\/query.php\u4e2d\u9996\u9875\u7f6e\u9876\u7684\u4ee3\u7801,\u7a0d\u5fae\u4fee\u6539\u4e00\u4e0b,\u53ef\u4ee5\u8ba9\u5206\u7c7b\u9875\u3001\u6807\u7b7e\u9875\u3001\u4f5c\u8005\u9875\u548c\u65e5\u671f\u9875\u7b49\u5b58\u6863\u9875\u9762\u4e5f\u80fd\u50cf\u9996\u9875\u4e00\u6837\u5728\u9876\u90e8\u663e\u793a\u5176\u8303\u56f4\u5185\u7684\u7f6e\u9876\u6587\u7ae0,\u628a\u4e0b\u9762\u7684\u4ee3\u7801\u653e\u5230\u5f53\u524d\u4e3b\u9898\u4e0b\u7684functions.php\u4e2d\u5c31\u53ef\u4ee5\u4e86.<\/p>\n<p>\u4ee3\u7801\u5982\u4e0b:<\/p>\n<pre>add_filter('the_posts',&nbsp;'putStickyOnTop'&nbsp;);&nbsp;\nfunction&nbsp;putStickyOnTop(&nbsp;$posts&nbsp;)&nbsp;{&nbsp;\nif(is_home()&nbsp;||&nbsp;!is_main_query()&nbsp;||&nbsp;!is_archive())&nbsp;\nreturn&nbsp;$posts;&nbsp;\nglobal&nbsp;$wp_query;&nbsp;\n$sticky_posts&nbsp;=&nbsp;get_option('sticky_posts');&nbsp;\nif&nbsp;(&nbsp;$wp_query-&amp;gt;query_vars['paged']&nbsp;&nbsp;$sticky_posts&nbsp;)&nbsp;);&nbsp;\nforeach&nbsp;(&nbsp;$stickies1&nbsp;as&nbsp;$sticky_post1&nbsp;)&nbsp;{&nbsp;\n\/\/&nbsp;\u5224\u65ad\u5f53\u524d\u662f\u5426\u5206\u7c7b\u9875&nbsp;\nif($wp_query-&amp;gt;is_category&nbsp;==&nbsp;1&nbsp;&amp;amp;&amp;amp;&nbsp;!has_category($wp_query-&amp;gt;query_vars['cat'],&nbsp;$sticky_post1-&amp;gt;ID))&nbsp;{&nbsp;\n\/\/&nbsp;\u53bb\u9664\u4e0d\u5c5e\u4e8e\u672c\u5206\u7c7b\u7684\u6587\u7ae0&nbsp;\n$offset1&nbsp;=&nbsp;array_search($sticky_post1-&amp;gt;ID,&nbsp;$sticky_posts);&nbsp;\nunset(&nbsp;$sticky_posts[$offset1]&nbsp;);&nbsp;\n}&nbsp;\nif($wp_query-&amp;gt;is_tag&nbsp;==&nbsp;1&nbsp;&amp;amp;&amp;amp;&nbsp;has_tag($wp_query-&amp;gt;query_vars['tag'],&nbsp;$sticky_post1-&amp;gt;ID))&nbsp;{&nbsp;\n\/\/&nbsp;\u53bb\u9664\u4e0d\u5c5e\u4e8e\u672c\u6807\u7b7e\u7684\u6587\u7ae0&nbsp;\n$offset1&nbsp;=&nbsp;array_search($sticky_post1-&amp;gt;ID,&nbsp;$sticky_posts);&nbsp;\nunset(&nbsp;$sticky_posts[$offset1]&nbsp;);&nbsp;\n}&nbsp;\nif($wp_query-&amp;gt;is_year&nbsp;==&nbsp;1&nbsp;&amp;amp;&amp;amp;&nbsp;date_i18n('Y',&nbsp;strtotime($sticky_post1-&amp;gt;post_date))!=$wp_query-&amp;gt;query['m'])&nbsp;{&nbsp;\n\/\/&nbsp;\u53bb\u9664\u4e0d\u5c5e\u4e8e\u672c\u5e74\u4efd\u7684\u6587\u7ae0&nbsp;\n$offset1&nbsp;=&nbsp;array_search($sticky_post1-&amp;gt;ID,&nbsp;$sticky_posts);&nbsp;\nunset(&nbsp;$sticky_posts[$offset1]&nbsp;);&nbsp;\n}&nbsp;\nif($wp_query-&amp;gt;is_month&nbsp;==&nbsp;1&nbsp;&amp;amp;&amp;amp;&nbsp;date_i18n('Ym',&nbsp;strtotime($sticky_post1-&amp;gt;post_date))!=$wp_query-&amp;gt;query['m'])&nbsp;{&nbsp;\n\/\/&nbsp;\u53bb\u9664\u4e0d\u5c5e\u4e8e\u672c\u6708\u4efd\u7684\u6587\u7ae0&nbsp;\n$offset1&nbsp;=&nbsp;array_search($sticky_post1-&amp;gt;ID,&nbsp;$sticky_posts);&nbsp;\nunset(&nbsp;$sticky_posts[$offset1]&nbsp;);&nbsp;\n}&nbsp;\nif($wp_query-&amp;gt;is_day&nbsp;==&nbsp;1&nbsp;&amp;amp;&amp;amp;&nbsp;date_i18n('Ymd',&nbsp;strtotime($sticky_post1-&amp;gt;post_date))!=$wp_query-&amp;gt;query['m'])&nbsp;{&nbsp;\n\/\/&nbsp;\u53bb\u9664\u4e0d\u5c5e\u4e8e\u672c\u65e5\u671f\u7684\u6587\u7ae0&nbsp;\n$offset1&nbsp;=&nbsp;array_search($sticky_post1-&amp;gt;ID,&nbsp;$sticky_posts);&nbsp;\nunset(&nbsp;$sticky_posts[$offset1]&nbsp;);&nbsp;\n}&nbsp;\nif($wp_query-&amp;gt;is_author&nbsp;==&nbsp;1&nbsp;&amp;amp;&amp;amp;&nbsp;$sticky_post1-&amp;gt;post_author&nbsp;!=&nbsp;$wp_query-&amp;gt;query_vars['author'])&nbsp;{&nbsp;\n\/\/&nbsp;\u53bb\u9664\u4e0d\u5c5e\u4e8e\u672c\u4f5c\u8005\u7684\u6587\u7ae0&nbsp;\n$offset1&nbsp;=&nbsp;array_search($sticky_post1-&amp;gt;ID,&nbsp;$sticky_posts);&nbsp;\nunset(&nbsp;$sticky_posts[$offset1]&nbsp;);&nbsp;\n}&nbsp;\n}&nbsp;\n$num_posts&nbsp;=&nbsp;count($posts);&nbsp;\n$sticky_offset&nbsp;=&nbsp;0;&nbsp;\n\/\/&nbsp;Loop&nbsp;over&nbsp;posts&nbsp;and&nbsp;relocate&nbsp;stickies&nbsp;to&nbsp;the&nbsp;front.&nbsp;\nfor&nbsp;(&nbsp;$i&nbsp;=&nbsp;0;&nbsp;$i&nbsp;ID,&nbsp;$sticky_posts)&nbsp;)&nbsp;{&nbsp;\n$sticky_post&nbsp;=&nbsp;$posts[$i];&nbsp;\n\/\/&nbsp;Remove&nbsp;sticky&nbsp;from&nbsp;current&nbsp;position&nbsp;\narray_splice($posts,&nbsp;$i,&nbsp;1);&nbsp;\n\/\/&nbsp;Move&nbsp;to&nbsp;front,&nbsp;after&nbsp;other&nbsp;stickies&nbsp;\narray_splice($posts,&nbsp;$sticky_offset,&nbsp;0,&nbsp;array($sticky_post));&nbsp;\n\/\/&nbsp;Increment&nbsp;the&nbsp;sticky&nbsp;offset.&nbsp;The&nbsp;next&nbsp;sticky&nbsp;will&nbsp;be&nbsp;placed&nbsp;at&nbsp;this&nbsp;offset.&nbsp;\n$sticky_offset++;&nbsp;\n\/\/&nbsp;Remove&nbsp;post&nbsp;from&nbsp;sticky&nbsp;posts&nbsp;array&nbsp;\n$offset&nbsp;=&nbsp;array_search($sticky_post-&amp;gt;ID,&nbsp;$sticky_posts);&nbsp;\nunset(&nbsp;$sticky_posts[$offset]&nbsp;);&nbsp;\n}&nbsp;\n}&nbsp;\n\/\/&nbsp;If&nbsp;any&nbsp;posts&nbsp;have&nbsp;been&nbsp;excluded&nbsp;specifically,&nbsp;Ignore&nbsp;those&nbsp;that&nbsp;are&nbsp;sticky.&nbsp;\nif&nbsp;(&nbsp;!emptyempty($sticky_posts)&nbsp;&amp;amp;&amp;amp;&nbsp;!emptyempty($wp_query-&amp;gt;query_vars['post__not_in']&nbsp;)&nbsp;)&nbsp;\n$sticky_posts&nbsp;=&nbsp;array_diff($sticky_posts,&nbsp;$wp_query-&amp;gt;query_vars['post__not_in']);&nbsp;\n\/\/&nbsp;Fetch&nbsp;sticky&nbsp;posts&nbsp;that&nbsp;weren't&nbsp;in&nbsp;the&nbsp;query&nbsp;results&nbsp;\nif&nbsp;(&nbsp;!emptyempty($sticky_posts)&nbsp;)&nbsp;{&nbsp;\n$stickies&nbsp;=&nbsp;get_posts(&nbsp;array(&nbsp;\n'post__in'&nbsp;=&amp;gt;&nbsp;$sticky_posts,&nbsp;\n'post_type'&nbsp;=&amp;gt;&nbsp;$wp_query-&amp;gt;query_vars['post_type'],&nbsp;\n'post_status'&nbsp;=&amp;gt;&nbsp;'publish',&nbsp;\n'nopaging'&nbsp;=&amp;gt;&nbsp;true&nbsp;\n)&nbsp;);&nbsp;\nforeach&nbsp;(&nbsp;$stickies&nbsp;as&nbsp;$sticky_post&nbsp;)&nbsp;{&nbsp;\narray_splice(&nbsp;$posts,&nbsp;$sticky_offset,&nbsp;0,&nbsp;array(&nbsp;$sticky_post&nbsp;)&nbsp;);&nbsp;\n$sticky_offset++;&nbsp;\n}&nbsp;\n}&nbsp;\n}&nbsp;\nreturn&nbsp;$posts;&nbsp;\n}<\/pre>\n<p> \u767b\u5f55\u540e\u590d\u5236 <\/p>\n<p>\u4ee3\u7801\u8bf4\u660e:<\/p>\n<p>1\u3001\u5982\u679c\u4f60\u60f3\u8ba9\u5b58\u6863\u9875\u4e5f\u90fd\u663e\u793a\u5168\u90e8\u7f6e\u9876\u6587\u7ae0,\u90a3\u4e48\u5c31\u5220\u638911-43\u884c\u7684\u4ee3\u7801\uff1b<\/p>\n<p>2\u3001\u5982\u679c\u4e0d\u60f3\u5728\u67d0\u5206\u7c7b\u9875\u663e\u793a\u7f6e\u9876\u6587\u7ae0,\u5c06\u7b2c 3 \u884c\u7684<\/p>\n<p>\u4ee3\u7801\u5982\u4e0b:<\/p>\n<pre>if(&nbsp;\n\/\/\u6539\u6210\uff1a&nbsp;\n\/\/&nbsp;abc\u662f\u5206\u7c7b\u540d\u79f0&nbsp;\nif&nbsp;(&nbsp;is_category(&nbsp;'abc'&nbsp;)&nbsp;||<\/pre>\n<p> \u767b\u5f55\u540e\u590d\u5236 <\/p>\n<p>3\u3001\u5982\u679c\u4e0d\u60f3\u67d0\u6807\u7b7e\u9875\u663e\u793a\u7f6e\u9876\u6587\u7ae0,\u5c06\u7b2c 3 \u884c\u7684\u4ee3\u7801<\/p>\n<p>\u4ee3\u7801\u5982\u4e0b:<\/p>\n<pre>if(&nbsp;\n\/\/\u6539\u6210\uff1a&nbsp;\n\/\/&nbsp;abc\u662f\u6807\u7b7e\u540d\u79f0&nbsp;\nif&nbsp;(&nbsp;is_tag(&nbsp;'abc'&nbsp;)&nbsp;||<\/pre>\n<p> \u767b\u5f55\u540e\u590d\u5236 <\/p>\n<p>4\u3001\u5982\u679c\u4e0d\u60f3\u67d0\u4f5c\u8005\u9875\u663e\u793a\u7f6e\u9876\u6587\u7ae0\uff0c\u5c06\u7b2c 3 \u884c\u7684<\/p>\n<p>\u4ee3\u7801\u5982\u4e0b:<\/p>\n<pre>if(&nbsp;\n\/\/\u6539\u6210\uff1a&nbsp;\n\/\/&nbsp;abc\u662f\u4f5c\u8005\u6635\u79f0&nbsp;\nif&nbsp;(&nbsp;is_author(&nbsp;'abc'&nbsp;)&nbsp;||<\/pre>\n<p> \u767b\u5f55\u540e\u590d\u5236 <\/p>\n<p>5\u3001\u4ee5\u4e0a\u4ee3\u7801\u53ea\u5bf9\u4e3b\u5faa\u73af\u6709\u6548,\u5982\u679c\u4f60\u5728\u5b58\u6863\u9875\u4f7f\u7528WP_Query\u6216query_posts\u6765\u83b7\u53d6\u6587\u7ae0\u5217\u8868,\u53c8\u50cf\u8ba9\u8fd9\u4e9b\u5217\u8868\u9876\u90e8\u663e\u793a\u7f6e\u9876\u6587\u7ae0,\u53ef\u4ee5\u628a\u7b2c3\u884c\u4ee3\u7801\u4e2d\u7684\u4ee5\u4e0b\u4ee3\u7801\u5220\u6389(\u6ce8\u610f:\u53ef\u80fd\u4f1a\u5bfc\u81f4\u6587\u7ae0\u663e\u793a\u6570\u91cf\u8ddf\u4f60\u8bbe\u7f6e\u7684\u4e0d\u4e00\u6837)\uff1a<\/p>\n<p>\u4ee3\u7801\u5982\u4e0b:<\/p>\n<p>\u4ee3\u7801\u5982\u4e0b:<\/p>\n<pre>||&nbsp;!is_main_query()<\/pre>\n<p> \u767b\u5f55\u540e\u590d\u5236 <\/p>\n<p>\u7f6e\u9876\u6837\u5f0f:\u5982\u679c\u4f60\u60f3\u7ed9\u7f6e\u9876\u6587\u7ae0\u6dfb\u52a0\u6837\u5f0f,\u5c06\u4ee5\u4e0b\u4ee3\u7801\u6dfb\u52a0\u5230functions.php\u4e2d,\u4f1a\u7ed9\u7f6e\u9876\u6587\u7ae0\u6dfb\u52a0\u4e00\u4e2a\u540d\u4e3a sticky \u7684class,\u5177\u4f53\u7684css\u4ee3\u7801,\u518d\u81ea\u884c\u81ea\u5b9a\u4e49\uff1a<\/p>\n<p>\u4ee3\u7801\u5982\u4e0b:<\/p>\n<pre>add_filter('post_class',&nbsp;'addStickyClass'&nbsp;,10,3&nbsp;);&nbsp;\nfunction&nbsp;addStickyClass(&nbsp;$classes,&nbsp;$class,&nbsp;$post_id&nbsp;){&nbsp;\nif(&nbsp;is_sticky()&nbsp;&amp;amp;&amp;amp;&nbsp;is_category()&nbsp;&amp;amp;&amp;amp;&nbsp;!isset(&nbsp;$classes['sticky']&nbsp;)&nbsp;){&nbsp;\n$classes[]&nbsp;=&nbsp;'sticky';&nbsp;\n}&nbsp;\nreturn&nbsp;$classes;&nbsp;\n}<\/pre>\n<p> \u767b\u5f55\u540e\u590d\u5236 <\/p>\n<p>\u5e0c\u671b\u672c\u6587\u6240\u8ff0\u5bf9\u5927\u5bb6\u7684\u6709\u6240\u5e2e\u52a9\u3002<\/p>\n<p>\u4ee5\u4e0a\u5c31\u662fWordPress\u5206\u7c7b\u4e0e\u6807\u7b7e\u7b49\u5b58\u6863\u9875\u600e\u4e48\u5b9e\u73b0\u7f6e\u9876\u7684\u8be6\u7ec6\u5185\u5bb9\uff0c\u66f4\u591a\u8bf7\u5173\u6ce8\u7c73\u4e91\u5176\u5b83\u76f8\u5173\u6587\u7ae0\uff01<\/p>\n","protected":false},"excerpt":{"rendered":"<p>\u5206\u7c7b\u4e0e\u6807\u7b7e\u7b49\u5b58\u6863\u9875\u600e\u4e48\u5b9e\u73b0\u7f6e\u9876\uff1f \u672c\u6587\u5b9e\u4f8b\u8bb2\u8ff0\u4e86WordPress\u5206\u7c7b\u4e0e\u6807\u7b7e\u7b49\u5b58\u6863\u9875\u5b9e\u73b0\u7f6e\u9876\u7684\u65b9\u6cd5\u3002\u5206\u4eab\u7ed9\u5927\u5bb6\u4f9b\u5927\u5bb6\u53c2\u8003\u3002\u5177\u4f53\u5206\u6790\u5982\u4e0b\uff1a \u63a8\u8350\uff1a\u300a\u300b \u5728wordpress\u4e2d\u9ed8\u8ba4\u80fd\u7f6e\u9876\u6587\u7ae0\u5c31\u662f\u53ea\u6709\u9996\u9875\u4e86,\u5982\u679c\u6211\u4eec\u5e0c\u671b\u5206\u7c7b\/\u6807\u7b7e\u7b49\u5b58\u6863\u9875\u4e5f\u80fd\u7f6e\u9876\u6587\u7ae0\u6211\u4eec\u9700\u8981\u4e8c\u6b21\u5f00\u53d1. \u73b0\u5728\u53c2\u8003wp-includes\/query.php\u4e2d\u9996\u9875\u7f6e\u9876\u7684\u4ee3\u7801,\u7a0d\u5fae\u4fee\u6539\u4e00\u4e0b,\u53ef\u4ee5\u8ba9\u5206\u7c7b\u9875\u3001\u6807\u7b7e\u9875\u3001\u4f5c\u8005\u9875\u548c\u65e5\u671f\u9875\u7b49\u5b58\u6863\u9875\u9762\u4e5f\u80fd\u50cf\u9996\u9875\u4e00\u6837\u5728\u9876\u90e8\u663e\u793a\u5176\u8303\u56f4\u5185\u7684\u7f6e\u9876\u6587\u7ae0,\u628a\u4e0b\u9762\u7684\u4ee3\u7801\u653e\u5230\u5f53\u524d\u4e3b\u9898\u4e0b\u7684functions.php\u4e2d\u5c31\u53ef\u4ee5\u4e86. \u4ee3\u7801\u5982\u4e0b: add_filter(&#8216;the_posts&#8217;,&nbsp;&#8216;putStickyOnTop&#8217;&nbsp;);&nbsp; function&nbsp;putStickyOnTop(&nbsp;$posts&nbsp;)&nbsp;{&nbsp; if(is_home()&nbsp;||&nbsp;!is_main_query()&nbsp;||&nbsp;!is_archive())&nbsp; return&nbsp;$posts;&nbsp; global&nbsp;$wp_query;&nbsp; $sticky_posts&nbsp;=&nbsp;get_option(&#8216;sticky_posts&#8217;);&nbsp; if&nbsp;(&nbsp;$wp_query-&amp;gt;query_vars[&#8216;paged&#8217;]&nbsp;&nbsp;$sticky_posts&nbsp;)&nbsp;);&nbsp; foreach&nbsp;(&nbsp;$stickies1&nbsp;as&nbsp;$sticky_post1&nbsp;)&nbsp;{&nbsp; \/\/&nbsp;\u5224\u65ad\u5f53\u524d\u662f\u5426\u5206\u7c7b\u9875&nbsp; if($wp_query-&amp;gt;is_category&nbsp;==&nbsp;1&nbsp;&amp;amp;&amp;amp;&nbsp;!has_category($wp_query-&amp;gt;query_vars[&#8216;cat&#8217;],&nbsp;$sticky_post1-&amp;gt;ID))&nbsp;{&nbsp; \/\/&nbsp;\u53bb\u9664\u4e0d\u5c5e\u4e8e\u672c\u5206\u7c7b\u7684\u6587\u7ae0&nbsp; $offset1&nbsp;=&nbsp;array_search($sticky_post1-&amp;gt;ID,&nbsp;$sticky_posts);&nbsp; unset(&nbsp;$sticky_posts[$offset1]&nbsp;);&nbsp; }&nbsp; if($wp_query-&amp;gt;is_tag&nbsp;==&nbsp;1&nbsp;&amp;amp;&amp;amp;&nbsp;has_tag($wp_query-&amp;gt;query_vars[&#8216;tag&#8217;],&nbsp;$sticky_post1-&amp;gt;ID))&nbsp;{&nbsp; \/\/&nbsp;\u53bb\u9664\u4e0d\u5c5e\u4e8e\u672c\u6807\u7b7e\u7684\u6587\u7ae0&nbsp; $offset1&nbsp;=&nbsp;array_search($sticky_post1-&amp;gt;ID,&nbsp;$sticky_posts);&nbsp; unset(&nbsp;$sticky_posts[$offset1]&nbsp;);&nbsp; }&nbsp; if($wp_query-&amp;gt;is_year&nbsp;==&nbsp;1&nbsp;&amp;amp;&amp;amp;&nbsp;date_i18n(&#8216;Y&#8217;,&nbsp;strtotime($sticky_post1-&amp;gt;post_date))!=$wp_query-&amp;gt;query[&#8216;m&#8217;])&nbsp;{&nbsp; \/\/&nbsp;\u53bb\u9664\u4e0d\u5c5e\u4e8e\u672c\u5e74\u4efd\u7684\u6587\u7ae0&nbsp; $offset1&nbsp;=&nbsp;array_search($sticky_post1-&amp;gt;ID,&nbsp;$sticky_posts);&nbsp; unset(&nbsp;$sticky_posts[$offset1]&nbsp;);&nbsp; }&nbsp; if($wp_query-&amp;gt;is_month&nbsp;==&nbsp;1&nbsp;&amp;amp;&amp;amp;&nbsp;date_i18n(&#8216;Ym&#8217;,&nbsp;strtotime($sticky_post1-&amp;gt;post_date))!=$wp_query-&amp;gt;query[&#8216;m&#8217;])&nbsp;{&nbsp; \/\/&nbsp;\u53bb\u9664\u4e0d\u5c5e\u4e8e\u672c\u6708\u4efd\u7684\u6587\u7ae0&nbsp; $offset1&nbsp;=&nbsp;array_search($sticky_post1-&amp;gt;ID,&nbsp;$sticky_posts);&nbsp; unset(&nbsp;$sticky_posts[$offset1]&nbsp;);&nbsp; }&nbsp; if($wp_query-&amp;gt;is_day&nbsp;==&nbsp;1&nbsp;&amp;amp;&amp;amp;&nbsp;date_i18n(&#8216;Ymd&#8217;,&nbsp;strtotime($sticky_post1-&amp;gt;post_date))!=$wp_query-&amp;gt;query[&#8216;m&#8217;])&nbsp;{&nbsp; \/\/&nbsp;\u53bb\u9664\u4e0d\u5c5e\u4e8e\u672c\u65e5\u671f\u7684\u6587\u7ae0&nbsp; $offset1&nbsp;=&nbsp;array_search($sticky_post1-&amp;gt;ID,&nbsp;$sticky_posts);&nbsp; unset(&nbsp;$sticky_posts[$offset1]&nbsp;);&nbsp; }&nbsp; if($wp_query-&amp;gt;is_author&nbsp;==&nbsp;1&nbsp;&amp;amp;&amp;amp;&nbsp;$sticky_post1-&amp;gt;post_author&nbsp;!=&nbsp;$wp_query-&amp;gt;query_vars[&#8216;author&#8217;])&nbsp;{&nbsp; \/\/&nbsp;\u53bb\u9664\u4e0d\u5c5e\u4e8e\u672c\u4f5c\u8005\u7684\u6587\u7ae0&nbsp; $offset1&nbsp;=&nbsp;array_search($sticky_post1-&amp;gt;ID,&nbsp;$sticky_posts);&nbsp; unset(&nbsp;$sticky_posts[$offset1]&nbsp;);&nbsp; }&nbsp; }&nbsp; $num_posts&nbsp;=&nbsp;count($posts);&nbsp; $sticky_offset&nbsp;=&nbsp;0;&nbsp; \/\/&nbsp;Loop&nbsp;over&nbsp;posts&nbsp;and&nbsp;relocate&nbsp;stickies&nbsp;to&nbsp;the&nbsp;front.&nbsp; for&nbsp;(&nbsp;$i&nbsp;=&nbsp;0;&nbsp;$i&nbsp;ID,&nbsp;$sticky_posts)&nbsp;)&nbsp;{&nbsp; $sticky_post&nbsp;=&nbsp;$posts[$i];&nbsp; \/\/&nbsp;Remove&nbsp;sticky&nbsp;from&nbsp;current&nbsp;position&nbsp; array_splice($posts,&nbsp;$i,&nbsp;1);&nbsp; \/\/&nbsp;Move&nbsp;to&nbsp;front,&nbsp;after&nbsp;other&nbsp;stickies&nbsp; array_splice($posts,&nbsp;$sticky_offset,&nbsp;0,&nbsp;array($sticky_post));&nbsp; [&hellip;]<\/p>\n","protected":false},"author":1,"featured_media":0,"comment_status":"closed","ping_status":"","sticky":false,"template":"","format":"standard","meta":{"footnotes":""},"categories":[18],"tags":[],"class_list":["post-30717","post","type-post","status-publish","format-standard","hentry","category-cms"],"_links":{"self":[{"href":"https:\/\/fwq.ai\/blog\/wp-json\/wp\/v2\/posts\/30717","targetHints":{"allow":["GET"]}}],"collection":[{"href":"https:\/\/fwq.ai\/blog\/wp-json\/wp\/v2\/posts"}],"about":[{"href":"https:\/\/fwq.ai\/blog\/wp-json\/wp\/v2\/types\/post"}],"author":[{"embeddable":true,"href":"https:\/\/fwq.ai\/blog\/wp-json\/wp\/v2\/users\/1"}],"replies":[{"embeddable":true,"href":"https:\/\/fwq.ai\/blog\/wp-json\/wp\/v2\/comments?post=30717"}],"version-history":[{"count":0,"href":"https:\/\/fwq.ai\/blog\/wp-json\/wp\/v2\/posts\/30717\/revisions"}],"wp:attachment":[{"href":"https:\/\/fwq.ai\/blog\/wp-json\/wp\/v2\/media?parent=30717"}],"wp:term":[{"taxonomy":"category","embeddable":true,"href":"https:\/\/fwq.ai\/blog\/wp-json\/wp\/v2\/categories?post=30717"},{"taxonomy":"post_tag","embeddable":true,"href":"https:\/\/fwq.ai\/blog\/wp-json\/wp\/v2\/tags?post=30717"}],"curies":[{"name":"wp","href":"https:\/\/api.w.org\/{rel}","templated":true}]}}