{"id":32589,"date":"2024-11-25T12:10:57","date_gmt":"2024-11-25T04:10:57","guid":{"rendered":"https:\/\/fwq.ai\/blog\/32589\/"},"modified":"2024-11-25T12:10:57","modified_gmt":"2024-11-25T04:10:57","slug":"%e5%bf%ab%e9%80%9f%e6%8f%90%e7%a4%ba%ef%bc%9a%e5%86%85%e5%ae%b9%e4%b9%8b%e5%90%8e-%e5%90%8c%e4%b8%80%e7%b1%bb%e5%88%ab%e7%9a%84%e6%9b%b4%e5%a4%9a%e5%86%85%e5%ae%b9","status":"publish","type":"post","link":"https:\/\/fwq.ai\/blog\/32589\/","title":{"rendered":"\u5feb\u901f\u63d0\u793a\uff1a\u5185\u5bb9\u4e4b\u540e &#8211; \u540c\u4e00\u7c7b\u522b\u7684\u66f4\u591a\u5185\u5bb9"},"content":{"rendered":"<p><img decoding=\"async\" src=\"https:\/\/img.php.cn\/upload\/article\/000\/465\/014\/169373478380746.jpg\" class=\"aligncenter\" title=\"\u5feb\u901f\u63d0\u793a\uff1a\u5185\u5bb9\u4e4b\u540e &#8211; \u540c\u4e00\u7c7b\u522b\u7684\u66f4\u591a\u5185\u5bb9\u63d2\u56fe\" alt=\"\u5feb\u901f\u63d0\u793a\uff1a\u5185\u5bb9\u4e4b\u540e &#8211; \u540c\u4e00\u7c7b\u522b\u7684\u66f4\u591a\u5185\u5bb9\u63d2\u56fe\" \/><\/p>\n<\/p>\n<p>\u60a8\u7684\u535a\u5ba2\u4e0a\u6709\u53ef\u9760\u7684\u7c7b\u522b\u7ed3\u6784\u5417\uff1f\u5982\u679c\u662f\u8fd9\u6837\uff0c\u60a8\u53ef\u80fd\u6839\u672c\u4e0d\u9700\u8981\u201c\u76f8\u5173\u5e16\u5b50\u201d\u90e8\u5206 &#8211; \u60a8\u53ea\u9700\u663e\u793a\u540c\u4e00\u7c7b\u522b\u7684\u6700\u65b0\u5e16\u5b50\u5373\u53ef\u3002<\/p>\n<p>\u5728\u8fd9\u7bc7\u6587\u7ae0\u4e2d\uff0c\u6211\u4eec\u5c06\u4ecb\u7ecd\u201c\u6b64\u7c7b\u522b\u7684\u66f4\u591a\u5185\u5bb9\u201d\u90e8\u5206\uff0c\u8fd9\u662f\u201c\u76f8\u5173\u5e16\u5b50\u201d\uff08\u6211\u4eec\u4e4b\u524d\u4ecb\u7ecd\u8fc7\uff09\u7684\u66ff\u4ee3\u9009\u9879\u3002 <\/p>\n<hr>\n<h2>\u8868\u660e\u4f60\u8fd8\u6709\u66f4\u591a\u8bdd\u8981\u8bf4<\/h2>\n<p>\u5982\u679c\u60a8\u5c06\u5e16\u5b50\u6309\u7c7b\u522b\u7ec4\u7ec7\u5f97\u5f88\u597d\uff0c\u60a8\u53ef\u80fd\u4f1a\u53d1\u73b0\u62e5\u6709\u5e16\u5b50\u7c7b\u522b\u4e2d\u7684\u5e16\u5b50\u5217\u8868\u5f88\u6709\u7528\u3002<\/p>\n<p>\u201c\u76f8\u5173\u5e16\u5b50\u201d\u5e76\u4e0d\u603b\u662f\u7b54\u6848\uff1a\u5982\u679c\u60a8\u7684\u7f51\u7ad9\u4e0a\u7684\u5e16\u5b50\u6309\u7c7b\u522b<em>\u5206\u9694<\/em>\uff0c\u90a3\u4e48\u201c\u76f8\u5173\u5e16\u5b50\u201d\u90e8\u5206\u53ef\u80fd\u4f1a\u201c\u6253\u7834\u201d\u8fd9\u79cd\u5206\u9694\u3002<\/p>\n<p>\u4f8b\u5982\uff0c\u5982\u679c\u60a8\u6709\u4e00\u4e2a\u5173\u4e8e\u4e0d\u540c\u804c\u4e1a\u7fa4\u4f53\u7684\u535a\u5ba2\uff0c\u5219\u65e0\u6cd5\u5728\u6709\u5173\u4fe1\u606f\u5b66\u7684\u5e16\u5b50\u4e0b\u5c06\u6709\u5173\u7eba\u7ec7\u884c\u4e1a\u7684\u65b0\u95fb\u663e\u793a\u4e3a\u201c\u76f8\u5173\u65b0\u95fb\u201d\u3002\u540c\u4e00\u7c7b\u522b\u7684\u8bb8\u591a\u6700\u65b0\u5e16\u5b50\u4f1a\u66f4\u76f8\u5173\uff0c\u5bf9\u5427\uff1f<\/p>\n<h3>\u521b\u5efa\u201c\u6b64\u7c7b\u522b\u7684\u66f4\u591a\u5185\u5bb9\u201d\u5217\u8868<\/h3>\n<p>\u6b63\u5982\u60a8\u53ef\u80fd\u5df2\u7ecf\u731c\u5230\u7684\uff0c\u5217\u51fa\u5e16\u5b50\u7c7b\u522b\u4e2d\u7684\u6700\u65b0\u5e16\u5b50\u6bd4\u6839\u636e\u5e16\u5b50\u6807\u7b7e\u663e\u793a\u76f8\u5173\u5e16\u5b50\u8981\u5bb9\u6613\u5f97\u591a\u3002\u6211\u4eec\u53ea\u9700\u8981\u83b7\u53d6\u5e16\u5b50\u7684\u7c7b\u522b\u5e76\u5217\u51fa\u8be5\u7c7b\u522b\u4e2d\u7684\u8bb8\u591a\u5e16\u5b50\uff0c\u4e0d\u5305\u62ec\u8bbf\u95ee\u8005\u521a\u521a\u9605\u8bfb\u7684\u5e16\u5b50\u3002\u6211\u4eec\u53ef\u4ee5\u5728 get_posts() \u51fd\u6570\u4e2d\u4f20\u9012\u7684\u53c2\u6570\u5305\u542b\u6211\u4eec\u9700\u8981\u7684\u4e00\u5207\u3002<\/p>\n<pre>\n&lt;?php \/\/ \"More from This Category\" list by Bar\u0131\u015f \u00dcnver @ Wptuts+\nfunction wptuts_more_from_cat( $title = \"More From This Category:\" ) {\n    global $post;\n    \/\/ We should get the first category of the post\n    $categories = get_the_category( $post-&gt;ID );\n    $first_cat = $categories[0]-&amp;gt;cat_ID;\n    \/\/ Let's start the $output by displaying the title and opening the <\/pre>\n<p> \u767b\u5f55\u540e\u590d\u5236 <\/p>\n<ul>\n  $output = &#8216; <\/p>\n<h3>&#8216; . $title . &#8216;<\/h3>\n<p>&#8216;; \/\/ The arguments of the post list! $args = array( \/\/ It should be in the first category of our post: &#8216;category__in&#8217; =&gt; array( $first_cat ), \/\/ Our post should NOT be in the list: &#8216;post__not_in&#8217; =&gt; array( $post-&gt;ID ), \/\/ &#8230;And it should fetch 5 posts &#8211; you can change this number if you like: &#8216;posts_per_page&#8217; =&gt; 5 ); \/\/ The get_posts() function $posts = get_posts( $args ); if( $posts ) { $output .= &#8216; <\/p>\n<ul>\n   &#8216;; \/\/ Let&#8217;s start the loop! foreach( $posts as $post ) { setup_postdata( $post ); $post_title = get_the_title(); $permalink = get_permalink(); $output .= &#8216; <\/p>\n<li><\/li>\n<p>&#8216;; } $output .= &#8216;\n <\/ul>\n<p>&#8216;; } else { \/\/ If there are no posts, we should return something, too! $output .= &#8216; <\/p>\n<p>Sorry, this category has just one post and you just read it!<\/p>\n<p>&#8216;; } \/\/ Let&#8217;s close the and return the $output: $output .= &#8216; &#8216;; return $output; } ?&gt; <\/p>\n<p>\u5b8c\u6210\uff01\u60a8\u53ef\u4ee5\u5c06\u6b64\u51fd\u6570\u5305\u542b\u5728\u60a8\u7684 <strong>functions.php<\/strong> \u6587\u4ef6\u4e2d\uff08\u6216\u5c06\u5176\u4fdd\u5b58\u4e3a\u5355\u72ec\u7684\u63d2\u4ef6\uff09\u5e76\u56de\u663e\u5b83\uff08\u5982 ) \u5728 <strong>single.php<\/strong> \u6587\u4ef6\u4e2d\u7684\u4efb\u4f55\u4f4d\u7f6e\u3002<\/p>\n<hr>\n<h2>\u7ed3\u8bba<\/h2>\n<p>\u662f\u7684\uff0c\u5185\u5bb9\u53ef\u80fd\u662f\u201c\u738b\u201d\uff0c\u4f46\u5b64\u72ec\u7684\u738b\u662f\u8f6f\u5f31\u7684\u738b\uff0c\u4eba\u4eec\u53ef\u80fd\u4e0d\u4f1a\u5c0a\u91cd\u90a3\u4e2a\u201c\u738b\u201d\u3002<\/p>\n<p>\u60a8\u8ba4\u4e3a\u8fd8\u6709\u66f4\u591a\u7684\u9875\u9762\u5143\u7d20\u53ef\u4ee5\u5e2e\u52a9\u201c\u738b\u201d\u5417\uff1f\u8bf7\u5728\u4e0b\u9762\u53d1\u8868\u60a8\u7684\u8bc4\u8bba &#8211; \u4e0e\u6211\u4eec\u5206\u4eab\u60a8\u7684\u60f3\u6cd5\u5bf9\u60a8\u6765\u8bf4\u59cb\u7ec8\u5f88\u91cd\u8981\uff01<\/p>\n<\/ul>\n<p>\u4ee5\u4e0a\u5c31\u662f\u5feb\u901f\u63d0\u793a\uff1a\u5185\u5bb9\u4e4b\u540e &#8211; \u540c\u4e00\u7c7b\u522b\u7684\u66f4\u591a\u5185\u5bb9\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>\u60a8\u7684\u535a\u5ba2\u4e0a\u6709\u53ef\u9760\u7684\u7c7b\u522b\u7ed3\u6784\u5417\uff1f\u5982\u679c\u662f\u8fd9\u6837\uff0c\u60a8\u53ef\u80fd\u6839\u672c\u4e0d\u9700\u8981\u201c\u76f8\u5173\u5e16\u5b50\u201d\u90e8\u5206 &#8211; \u60a8\u53ea\u9700\u663e\u793a\u540c\u4e00\u7c7b\u522b\u7684\u6700\u65b0\u5e16\u5b50\u5373\u53ef\u3002 \u5728\u8fd9\u7bc7\u6587\u7ae0\u4e2d\uff0c\u6211\u4eec\u5c06\u4ecb\u7ecd\u201c\u6b64\u7c7b\u522b\u7684\u66f4\u591a\u5185\u5bb9\u201d\u90e8\u5206\uff0c\u8fd9\u662f\u201c\u76f8\u5173\u5e16\u5b50\u201d\uff08\u6211\u4eec\u4e4b\u524d\u4ecb\u7ecd\u8fc7\uff09\u7684\u66ff\u4ee3\u9009\u9879\u3002 \u8868\u660e\u4f60\u8fd8\u6709\u66f4\u591a\u8bdd\u8981\u8bf4 \u5982\u679c\u60a8\u5c06\u5e16\u5b50\u6309\u7c7b\u522b\u7ec4\u7ec7\u5f97\u5f88\u597d\uff0c\u60a8\u53ef\u80fd\u4f1a\u53d1\u73b0\u62e5\u6709\u5e16\u5b50\u7c7b\u522b\u4e2d\u7684\u5e16\u5b50\u5217\u8868\u5f88\u6709\u7528\u3002 \u201c\u76f8\u5173\u5e16\u5b50\u201d\u5e76\u4e0d\u603b\u662f\u7b54\u6848\uff1a\u5982\u679c\u60a8\u7684\u7f51\u7ad9\u4e0a\u7684\u5e16\u5b50\u6309\u7c7b\u522b\u5206\u9694\uff0c\u90a3\u4e48\u201c\u76f8\u5173\u5e16\u5b50\u201d\u90e8\u5206\u53ef\u80fd\u4f1a\u201c\u6253\u7834\u201d\u8fd9\u79cd\u5206\u9694\u3002 \u4f8b\u5982\uff0c\u5982\u679c\u60a8\u6709\u4e00\u4e2a\u5173\u4e8e\u4e0d\u540c\u804c\u4e1a\u7fa4\u4f53\u7684\u535a\u5ba2\uff0c\u5219\u65e0\u6cd5\u5728\u6709\u5173\u4fe1\u606f\u5b66\u7684\u5e16\u5b50\u4e0b\u5c06\u6709\u5173\u7eba\u7ec7\u884c\u4e1a\u7684\u65b0\u95fb\u663e\u793a\u4e3a\u201c\u76f8\u5173\u65b0\u95fb\u201d\u3002\u540c\u4e00\u7c7b\u522b\u7684\u8bb8\u591a\u6700\u65b0\u5e16\u5b50\u4f1a\u66f4\u76f8\u5173\uff0c\u5bf9\u5427\uff1f \u521b\u5efa\u201c\u6b64\u7c7b\u522b\u7684\u66f4\u591a\u5185\u5bb9\u201d\u5217\u8868 \u6b63\u5982\u60a8\u53ef\u80fd\u5df2\u7ecf\u731c\u5230\u7684\uff0c\u5217\u51fa\u5e16\u5b50\u7c7b\u522b\u4e2d\u7684\u6700\u65b0\u5e16\u5b50\u6bd4\u6839\u636e\u5e16\u5b50\u6807\u7b7e\u663e\u793a\u76f8\u5173\u5e16\u5b50\u8981\u5bb9\u6613\u5f97\u591a\u3002\u6211\u4eec\u53ea\u9700\u8981\u83b7\u53d6\u5e16\u5b50\u7684\u7c7b\u522b\u5e76\u5217\u51fa\u8be5\u7c7b\u522b\u4e2d\u7684\u8bb8\u591a\u5e16\u5b50\uff0c\u4e0d\u5305\u62ec\u8bbf\u95ee\u8005\u521a\u521a\u9605\u8bfb\u7684\u5e16\u5b50\u3002\u6211\u4eec\u53ef\u4ee5\u5728 get_posts() \u51fd\u6570\u4e2d\u4f20\u9012\u7684\u53c2\u6570\u5305\u542b\u6211\u4eec\u9700\u8981\u7684\u4e00\u5207\u3002 &lt;?php \/\/ &#8220;More from This Category&#8221; list by Bar\u0131\u015f \u00dcnver @ Wptuts+ function wptuts_more_from_cat( $title = &#8220;More From This Category:&#8221; ) { global $post; \/\/ We should get the first category of the post $categories = get_the_category( $post-&gt;ID ); $first_cat = $categories[0]-&amp;gt;cat_ID; \/\/ [&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-32589","post","type-post","status-publish","format-standard","hentry","category-cms"],"_links":{"self":[{"href":"https:\/\/fwq.ai\/blog\/wp-json\/wp\/v2\/posts\/32589","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=32589"}],"version-history":[{"count":0,"href":"https:\/\/fwq.ai\/blog\/wp-json\/wp\/v2\/posts\/32589\/revisions"}],"wp:attachment":[{"href":"https:\/\/fwq.ai\/blog\/wp-json\/wp\/v2\/media?parent=32589"}],"wp:term":[{"taxonomy":"category","embeddable":true,"href":"https:\/\/fwq.ai\/blog\/wp-json\/wp\/v2\/categories?post=32589"},{"taxonomy":"post_tag","embeddable":true,"href":"https:\/\/fwq.ai\/blog\/wp-json\/wp\/v2\/tags?post=32589"}],"curies":[{"name":"wp","href":"https:\/\/api.w.org\/{rel}","templated":true}]}}