{"id":989,"date":"2024-06-05T20:33:41","date_gmt":"2024-06-05T12:33:41","guid":{"rendered":"https:\/\/cn.raksmart.com\/blog\/host\/4153.html"},"modified":"2024-06-05T20:33:41","modified_gmt":"2024-06-05T12:33:41","slug":"wordpress%e8%8e%b7%e5%8f%96%e8%87%aa%e5%ae%9a%e4%b9%89%e5%88%86%e7%b1%bb%e5%92%8c%e6%a0%87%e7%ad%be%e6%96%87%e7%ab%a0%e6%95%b0%e6%96%b9%e6%b3%95","status":"publish","type":"post","link":"https:\/\/cn.raksmart.com\/blog\/website\/wordpress\/989.html","title":{"rendered":"WordPress\u83b7\u53d6\u81ea\u5b9a\u4e49\u5206\u7c7b\u548c\u6807\u7b7e\u6587\u7ae0\u6570\u65b9\u6cd5"},"content":{"rendered":"<div class=\"entry-content e-content\" itemprop=\"description articleBody\">\n<p>\u3000\u3000<strong>WordPress<\/strong>\u83b7\u53d6\u5206\u7c7b\u3001\u81ea\u5b9a\u4e49\u5206\u7c7b\u548c\u6807\u7b7e\u4e0b\u7684\u6587\u7ae0\u603b\u6570\u662f\u5f88\u591a\u7f51\u7ad9\u90fd\u9700\u8981\u7684\u529f\u80fd\uff0c\u5176\u4e2d\u83b7\u53d6\u5206\u7c7b\u4e0b\u7684\u6587\u7ae0\u6570\u6bd4\u8f83\u5bb9\u6613\u5b9e\u73b0\uff0c\u4f46\u81ea\u5b9a\u4e49\u5206\u7c7b\u548c\u6807\u7b7e\u4e0b\u7684\u6587\u7ae0\u603b\u6570\u83b7\u53d6\u7f51\u4e0a\u7684\u4e00\u4e9b\u65b9\u6cd5\u4e0d\u662f\u5f88\u5b9e\u7528\u3002\u5728\u7ed9\u4e00\u4e2a\u7f51\u7ad9\u505a\u8fd9\u4e2a\u529f\u80fd\u65f6\u987a\u4fbf\u628a\u76f8\u5173\u65b9\u6cd5\u5206\u4eab\u51fa\u6765\uff0c\u4fbf\u4e8e\u5404\u4f4d\u540c\u5b66\u5feb\u901f\u89e3\u51b3\u95ee\u9898\uff0c\u5c31\u4e0d\u7528\u518d\u82b1\u597d\u591a\u65f6\u95f4\u53bb\u67e5\u627e\u4e86\u3002\u4ee5\u4e0b\u662f<strong><a href=\"https:\/\/www.raksmart.com\/cps\/7821\" target=\"_blank\" rel=\"noopener\">raksmart<\/a><a href=\"https:\/\/cn.raksmart.com\/\" target=\"_blank\" rel=\"noreferrer noopener\" aria-label=\"\u7f8e\u56fd\u670d\u52a1\u5668\uff08\u5728\u65b0\u7a97\u53e3\u6253\u5f00\uff09\">\u7f8e\u56fd\u670d\u52a1\u5668<\/a><\/strong>\u603b\u7ed3\u7684\u5177\u4f53\u5b9e\u73b0\u65b9\u6cd5\u3002<\/p>\n<p>\u3000\u3000\u4e0b\u9762\u7684\u524d\u4e09\u79cd\u65b9\u6cd5\u4e3a\u4e0d\u540c\u7684\u83b7\u53d6\u5206\u7c7b\u548c\u6807\u7b7e\u6587\u7ae0\u6570\u7684\u57fa\u672c\u65b9\u6cd5\uff0c\u8fd9\u4e09\u79cd\u57fa\u672c\u65b9\u6cd5\u90fd\u53ea\u80fd\u6839\u636e\u5355\u4e2a\u8f93\u5165\u7684\u5177\u4f53\u540d\u79f0\u3001\u6807\u7b7e\u540d\u3001\u5206\u7c7bID\u6216\u522b\u540d\u6765\u83b7\u53d6\u6587\u7ae0\u6570\u3002\u7b2c\u56db\u79cd\u65b9\u6cd5\u662f\u4e00\u4e2a\u901a\u7528\u6027\u65b9\u6cd5\uff0c\u4f7f\u7528\u4ef7\u503c\u6700\u9ad8\uff0c\u53ef\u81ea\u52a8\u6839\u636e\u5f53\u524d\u5206\u7c7b\u6cd5\u9875\u7684ID\u6765\u83b7\u53d6\u6587\u7ae0\u6570\u3002<\/p>\n<p class=\"has-text-color has-vivid-red-color\">\u3000\u30001\u3001\u6839\u636e\u5206\u7c7b\u540d\u79f0\u83b7\u53d6\u6587\u7ae0\u6570\u3002<\/p>\n<p>\u3000\u3000$taxonomy = \u201ccategory\u201d; \/\/ \u53ef\u4ee5\u662fcategory\u3001post_tag\u3001\u6216\u81ea\u5b9a\u4e49\u5206\u7c7b\u540d<\/p>\n<p>\u3000\u3000\/\/ \u7528\u5206\u7c7b\u540d\uff0c\u66ff\u6362\u6210\u4f60\u81ea\u5df1\u7684<\/p>\n<p>\u3000\u3000$term_name = \u2018A Category\u2019;<\/p>\n<p>\u3000\u3000$term = get_term_by(\u2018name\u2019, $term_name, $taxonomy);<\/p>\n<p>\u3000\u3000\/\/ \u83b7\u53d6\u6587\u7ae0\u6570<\/p>\n<p>\u3000\u3000echo $term-&gt;count; \u63a8\u8350\u9605\u8bfb\uff1a<a href=\"https:\/\/cn.raksmart.com\/blog\/website\/wordpress\/775.html\">\u4ec0\u4e48\u662fWORDPRESS\u63d2\u4ef6, \u5982\u4f55\u5b89\u88c5?<\/a><\/p>\n<p class=\"has-text-color has-vivid-red-color\">\u3000\u30002\u3001\u6839\u636e\u5206\u7c7bID\u83b7\u53d6\u6587\u7ae0\u6570\u3002<\/p>\n<p>\u3000\u3000$taxonomy = \u201ccategory\u201d; \/\/ \u53ef\u4ee5\u662fcategory\u3001post_tag\u3001\u6216\u81ea\u5b9a\u4e49\u5206\u7c7b\u540d<\/p>\n<p>\u3000\u3000\/\/ \u7528\u5206\u7c7bID\uff0c\u66ff\u6362\u6210\u4f60\u81ea\u5df1\u7684<\/p>\n<p>\u3000\u3000$term_id = 1;<\/p>\n<p>\u3000\u3000$term = get_term_by(\u2018id\u2019, $term_id, $taxonomy);<\/p>\n<p>\u3000\u3000\/\/ \u83b7\u53d6\u6587\u7ae0\u6570<\/p>\n<p>\u3000\u3000echo $term-&gt;count;<\/p>\n<p class=\"has-text-color has-vivid-red-color\">\u3000\u30003\u3001\u6839\u636e\u5206\u7c7bslug\u522b\u540d\u83b7\u53d6\u6587\u7ae0\u6570\u3002<\/p>\n<p>\u3000\u3000$taxonomy = \u201ccategory\u201d; \/\/ \u53ef\u4ee5\u662fcategory\u3001post_tag\u3001\u6216\u81ea\u5b9a\u4e49\u5206\u7c7b\u540d<\/p>\n<p>\u3000\u3000\/\/ \u7528\u5206\u7c7bslug\u522b\u540d\uff0c\u66ff\u6362\u6210\u4f60\u81ea\u5df1\u7684<\/p>\n<p>\u3000\u3000$term_slug = \u2018a-category\u2019;<\/p>\n<p>\u3000\u3000$term = get_term_by(\u2018slug\u2019, $term_slug, $taxonomy);<\/p>\n<p>\u3000\u3000\/\/ \u83b7\u53d6\u6587\u7ae0\u6570<\/p>\n<p>\u3000\u3000echo $term-&gt;count;<\/p>\n<p class=\"has-text-color has-vivid-red-color\">\u3000\u30004\u3001\u901a\u7528\u578b\u5b9e\u4f8b\u4ee3\u7801\uff1a\u53ef\u83b7\u53d6\u5206\u7c7b\u3001\u81ea\u5b9a\u4e49\u5206\u7c7b\u3001\u6807\u7b7e\u7b49\u4efb\u4f55\u5206\u7c7b\u6cd5\u4e0b\u7684\u6587\u7ae0\u6570\u3002<\/p>\n<p>\u3000\u3000\/*<\/p>\n<p>\u3000\u3000\u53ef\u7528\u4e8e\u83b7\u53d6\u4efb\u4f55\u5206\u7c7b\u6cd5\u4e0b\u7684\u6587\u7ae0\u6570<\/p>\n<p>\u3000\u3000\u4ee3\u7801\u6765\u6e90: www.wpzhinan.com\/jiaocheng\/1793.html<\/p>\n<p>\u3000\u3000*\/<\/p>\n<p>\u3000\u3000\u5171\u6709term_id; \/\/ \u81ea\u52a8\u6839\u636e\u5f53\u524d\u5206\u7c7b\u9875\u83b7\u53d6term id<\/p>\n<p>\u3000\u3000$term = get_term_by(\u2018id\u2019, $term_id, $taxonomy);<\/p>\n<p>\u3000\u3000echo $term-&gt;count; \/\/ \u83b7\u53d6\u6587\u7ae0\u6570<\/p>\n<p>\u3000\u3000?&gt;\u7bc7\u6587\u7ae0<\/p>\n<p>\u3000\u3000\u4ee3\u7801\u8bf4\u660e\uff1a\u8fd9\u4e2a\u662f\u76ee\u524d\u81ea\u5df1\u5728\u7528\u7684\u65b9\u6cd5\uff0c\u539f\u7406\u662f\u81ea\u52a8\u83b7\u53d6\u5f53\u524d\u6240\u5728\u5206\u7c7b\u9875\u9762\u7684term id\u5e76\u4ee5\u5206\u7c7bID\u6765\u83b7\u53d6\u5176\u4e0b\u9762\u7684\u6587\u7ae0\u6570\u3002\u8fd9\u6837\u505a\u7684\u597d\u5904\u662f\u901a\u7528\u6027\u975e\u5e38\u5f3a\uff0c\u53ef\u7528\u4e8e\u4efb\u4f55\u5206\u7c7b\u6cd5taxonomy\u7684\u9875\u9762\uff0c\u5305\u62ec\u9ed8\u8ba4\u6587\u7ae0\u5206\u7c7b\u548c\u6807\u7b7e\u3002\u4f7f\u7528\u7684\u65f6\u5019\uff0c\u53ea\u9700\u4fee\u6539\u4f60\u8981\u83b7\u53d6\u7684\u5206\u7c7b\u7c7b\u578b\u540d\u5373\u53ef\u3002\u60f3\u4e86\u89e3\u66f4\u591a\u5185\u5bb9\u53ef\u4ee5\u9605\u8bfb\uff1a<a href=\"https:\/\/cn.raksmart.com\/blog\/website\/wordpress\/727.html\">WORDPRESS\u53d1\u5e03\u548c\u5904\u7406\u6587\u7ae0\u529f\u80fd\uff081\uff09<\/a><\/p>\n<p>\u00a0<\/p>\n","protected":false},"excerpt":{"rendered":"<p>\u3000\u3000WordPress\u83b7\u53d6\u5206\u7c7b\u3001\u81ea\u5b9a\u4e49\u5206\u7c7b\u548c\u6807\u7b7e\u4e0b\u7684\u6587\u7ae0\u603b\u6570\u662f\u5f88\u591a\u7f51\u7ad9\u90fd\u9700\u8981\u7684\u529f\u80fd\uff0c\u5176\u4e2d\u83b7\u53d6\u5206\u7c7b\u4e0b\u7684\u2026 <\/p>\n","protected":false},"author":1,"featured_media":0,"comment_status":"open","ping_status":"open","sticky":false,"template":"","format":"standard","meta":{"footnotes":""},"categories":[23],"tags":[617],"class_list":["post-989","post","type-post","status-publish","format-standard","hentry","category-wordpress","tag-wordpress"],"_links":{"self":[{"href":"https:\/\/cn.raksmart.com\/blog\/wp-json\/wp\/v2\/posts\/989","targetHints":{"allow":["GET"]}}],"collection":[{"href":"https:\/\/cn.raksmart.com\/blog\/wp-json\/wp\/v2\/posts"}],"about":[{"href":"https:\/\/cn.raksmart.com\/blog\/wp-json\/wp\/v2\/types\/post"}],"author":[{"embeddable":true,"href":"https:\/\/cn.raksmart.com\/blog\/wp-json\/wp\/v2\/users\/1"}],"replies":[{"embeddable":true,"href":"https:\/\/cn.raksmart.com\/blog\/wp-json\/wp\/v2\/comments?post=989"}],"version-history":[{"count":0,"href":"https:\/\/cn.raksmart.com\/blog\/wp-json\/wp\/v2\/posts\/989\/revisions"}],"wp:attachment":[{"href":"https:\/\/cn.raksmart.com\/blog\/wp-json\/wp\/v2\/media?parent=989"}],"wp:term":[{"taxonomy":"category","embeddable":true,"href":"https:\/\/cn.raksmart.com\/blog\/wp-json\/wp\/v2\/categories?post=989"},{"taxonomy":"post_tag","embeddable":true,"href":"https:\/\/cn.raksmart.com\/blog\/wp-json\/wp\/v2\/tags?post=989"}],"curies":[{"name":"wp","href":"https:\/\/api.w.org\/{rel}","templated":true}]}}