{"id":32575,"date":"2024-11-25T14:19:29","date_gmt":"2024-11-25T06:19:29","guid":{"rendered":"https:\/\/fwq.ai\/blog\/32575\/"},"modified":"2024-11-25T14:19:29","modified_gmt":"2024-11-25T06:19:29","slug":"%e6%8e%a2%e7%b4%a2-wordpress-%e5%85%a8%e5%b1%80%e5%8f%98%e9%87%8f%ef%bc%9a%e5%88%9d%e5%ad%a6%e8%80%85%e6%8c%87%e5%8d%97","status":"publish","type":"post","link":"https:\/\/fwq.ai\/blog\/32575\/","title":{"rendered":"\u63a2\u7d22 WordPress \u5168\u5c40\u53d8\u91cf\uff1a\u521d\u5b66\u8005\u6307\u5357"},"content":{"rendered":"<\/p>\n<p>\u5728\u8fd9\u4e2a\u7531\u4e09\u90e8\u5206\u7ec4\u6210\u7684\u7cfb\u5217\u4e2d\uff0c\u6211\u4eec\u5c06\u7814\u7a76 wordpress \u5168\u5c40\u53d8\u91cf\uff0c\u4ee5\u4fbf\u66f4\u597d\u5730\u4e86\u89e3\u5b83\u4eec\uff0c\u4ee5\u4fbf\u6211\u4eec\u53ef\u4ee5\u5c06\u5b83\u4eec\u5e94\u7528\u5230\u65e5\u5e38\u5f00\u53d1\u4e2d\u3002<\/p>\n<p>\u5728\u6574\u4e2a\u7cfb\u5217\u4e2d\uff0c\u6211\u4eec\u5c06\u8fdb\u884c\u4e00\u7cfb\u5217\u5b9e\u8df5\u7ec3\u4e60\uff0c\u5c55\u793a\u5168\u5c40\u53d8\u91cf\u5728\u663e\u793a\u548c\u8c03\u6574 WordPress \u5185\u90e8\u5de5\u4f5c\u65b9\u9762\u7684\u5f3a\u5927\u529f\u80fd\u3002<\/p>\n<h2>\u4ec0\u4e48\u662f WordPress \u5168\u5c40\u53d8\u91cf\uff1f<\/h2>\n<p>WordPress \u5168\u5c40\u53d8\u91cf\u662f\u4fdd\u5b58\u5e94\u7528\u7a0b\u5e8f\u751f\u6210\u7684\u4fe1\u606f\u7684\u53d8\u91cf\u3002\u53ef\u4ee5\u5728\u5e94\u7528\u7a0b\u5e8f\u6267\u884c\u671f\u95f4\u548c\u9875\u9762\u751f\u547d\u5468\u671f\u671f\u95f4\u8bbf\u95ee\u8fd9\u4e9b\u5168\u5c40\u53d8\u91cf\u3002 <\/p>\n<p>\u8fd9\u4e9b\u53d8\u91cf\u4fdd\u5b58\u5404\u79cd\u4fe1\u606f\uff0c\u4f8b\u5982\u7528\u6237\u662f\u5426\u767b\u5f55\u3001\u7528\u6237\u8bbf\u95ee\u7f51\u7ad9\u65f6\u4f7f\u7528\u7684\u6d4f\u89c8\u5668\u7b49\u7b49\u3002\u6709\u4e9b\u53d8\u91cf\u4fdd\u5b58 Web \u670d\u52a1\u5668\u7684\u8be6\u7ec6\u4fe1\u606f\uff0c\u8fd8\u6709\u4e00\u4e9b\u53d8\u91cf\u4fdd\u5b58\u5f53\u524d\u5e16\u5b50\u7684\u8be6\u7ec6\u4fe1\u606f\u3002\u53ef\u4ee5\u8bbf\u95ee\u5168\u5c40\u53d8\u91cf\u7684\u503c\u6765\u4e86\u89e3 WordPress \u7684\u5185\u90e8\u5de5\u4f5c\u539f\u7406\uff0c\u4ee5\u4fbf\u5f00\u59cb\u5728\u4e3b\u9898\u548c\u63d2\u4ef6\u4e2d\u5f15\u5165\u65b0\u529f\u80fd\u3002<\/p>\n<h2>\u6211\u4eec\u5982\u4f55\u8bbf\u95ee\u5168\u5c40\u53d8\u91cf\uff1f<\/h2>\n<p>\u5728\u6211\u4eec\u7684\u7b2c\u4e00\u4e2a\u793a\u4f8b\u4e2d\uff0c\u6211\u4eec\u5c06\u4f7f\u7528 $post \u5168\u5c40\u53d8\u91cf\u6765\u4fdd\u5b58\u6709\u5173\u5f53\u524d\u5e16\u5b50\u6570\u636e\u7684\u5404\u79cd\u8be6\u7ec6\u4fe1\u606f\u3002 <\/p>\n<p>\u6bcf\u4e2a\u5168\u5c40\u53d8\u91cf\u90fd\u53ef\u4ee5\u901a\u8fc7\u5982\u4e0b\u65b9\u5f0f\u5168\u5c40\u5316\u53d8\u91cf\u6765\u8bbf\u95ee\uff1a&nbsp; &nbsp;<\/p>\n<pre>&lt;?php global $post; ?&gt;<\/pre>\n<p>  \u767b\u5f55\u540e\u590d\u5236   <\/p>\n<p>\u901a\u8fc7\u4f7f\u7528 global \u5173\u952e\u5b57\uff0c\u6211\u4eec\u58f0\u660e\u6211\u4eec\u6b63\u5728\u8bbf\u95ee $post \u5168\u5c40\u53d8\u91cf\u3002\u4e00\u65e6\u53d8\u91cf\u88ab\u5168\u7403\u5316\uff0c\u53ef\u4ee5\u4f7f\u7528\u4ee5\u4e0b\u6e90\u4ee3\u7801\u68c0\u7d22\u53ef\u8bbf\u95ee\u7684\u5404\u79cd\u503c\uff1a<\/p>\n<pre>&lt;?php global $post;\n    print_r ($post );\n<\/pre>\n<p>  \u767b\u5f55\u540e\u590d\u5236   <\/p>\n<p>$post&nbsp;\u5168\u5c40\u53d8\u91cf\u5305\u542b\u6709\u5173\u6700\u8fd1\u52a0\u8f7d\u7684\u5e16\u5b50\u7684\u5404\u79cd\u6570\u636e\u3002\u7ee7\u7eed\u5c06\u4e0a\u9762\u7684\u4ee3\u7801\u7247\u6bb5\u63d2\u5165\u5230\u4e8c\u5341\u56db\u4e3b\u9898\u7684 page.php \u4e2d\uff08\u5c3d\u7ba1\u6211\u5efa\u8bae\u5728\u8fdb\u884c\u8fd9\u4e9b\u66f4\u6539\u4e4b\u524d\u5907\u4efd\u4e3b\u9898\uff09\u3002<\/p>\n<p>\u5c06\u4e0a\u9762\u7684\u4ee3\u7801\u7247\u6bb5\u7c98\u8d34\u5230 get_template_part( \u2018content\u2019, \u2018page\u2019 ) \u4e4b\u540e\uff0c\u5b83\u4f1a\u83b7\u53d6\u5185\u5bb9\u5e76\u5c06\u5176\u663e\u793a\u5728\u9875\u9762\u4e0a\u3002\u8fd9\u662f\u6211\u4eec\u5230\u76ee\u524d\u4e3a\u6b62\u5728 page.php \u4e0a\u5e94\u8be5\u62e5\u6709\u7684\u5185\u5bb9\uff1a<\/p>\n<pre>&lt;div id=\"primary\" class=\"content-area\"&gt;\n\n    &lt;div id=\"content\" class=\"site-content\" role=\"main\"&gt;\n\n    &lt;?php \/\/ Start the Loop.\n\n       while ( have_posts() ) : the_post();\n\n       \/\/Include the page content template.\n\n       get_template_part( 'content', 'page' );\n\n       \/\/ Paste Snippet Here\n\n       global $post;\n       print_r( $post );\n       \n       \/\/ End Snippet \n\n       \/\/ If comments are open or we have at least one comment\n\n      if ( comments_open() || get_comments_number() ) {\n\n        comments_template();\n\n      }\n\nendwhile;\n\n?&gt;\n&lt;\/div&gt;\n&lt;!-- #content --&gt;\n\n&lt;\/div&gt; &lt;!-- #primary --&gt;\n<\/pre>\n<p>  \u767b\u5f55\u540e\u590d\u5236   <\/p>\n<p>\u73b0\u5728\u6211\u4eec\u6709\u4e86\u4e0a\u9762\u7684\u4ee3\u7801\u6765\u516c\u5f00\u5168\u5c40 $post \u53d8\u91cf\u7684\u6570\u636e\uff0c\u4fdd\u5b58\u6587\u4ef6\u5e76\u5728\u786e\u8ba4\u5f53\u524d\u4e3b\u9898\u4e3a\u4e8c\u5341\u56db\u540e\u7ee7\u7eed\u6253\u5f00\u4efb\u4f55\u9875\u9762\u3002\u5982\u679c\u6ca1\u6709\uff0c\u8bf7\u7ee7\u7eed\u5c06\u5176\u8bbe\u4e3a\u5f53\u524d\u4e3b\u9898\u3002 <\/p>\n<p>\u73b0\u5728\u89c2\u5bdfWordPress\u6253\u5370\u7684\u8be6\u7ec6\u4fe1\u606f\uff1b\u6211\u4eec\u5e94\u8be5\u770b\u5230\u8fd9\u6837\u7684\u4e1c\u897f\uff1a<\/p>\n<p><img decoding=\"async\" src=\"https:\/\/img.php.cn\/upload\/article\/000\/465\/014\/169372566621817.jpg\" class=\"aligncenter\" title=\"\u63a2\u7d22 WordPress \u5168\u5c40\u53d8\u91cf\uff1a\u521d\u5b66\u8005\u6307\u5357\u63d2\u56fe\" alt=\"\u63a2\u7d22 WordPress \u5168\u5c40\u53d8\u91cf\uff1a\u521d\u5b66\u8005\u6307\u5357\u63d2\u56fe\" \/><\/p>\n<p>\u5982\u60a8\u6240\u89c1\uff0c\u6211\u4eec\u73b0\u5728\u4ece $post&nbsp;\u5168\u5c40\u53d8\u91cf\u4e2d\u4ee5\u4eba\u7c7b\u53ef\u8bfb\u7684\u683c\u5f0f\u6253\u5370\u4e86\u6700\u65b0\u5e16\u5b50\u7684\u5404\u79cd\u8be6\u7ec6\u4fe1\u606f\u3002\u6211\u4eec\u53ef\u4ee5\u901a\u8fc7\u5982\u4e0b\u8c03\u7528\u6765\u8bbf\u95ee\u6bcf\u4e2a\u5355\u72ec\u7684\u503c\uff1a<\/p>\n<pre>&lt;?php echo $post-&gt;post_date;    \/\/ To Print the Date of the Post\n    echo $post-&amp;gt;post_status;  \/\/ To print the status of the Post \n<\/pre>\n<p>  \u767b\u5f55\u540e\u590d\u5236   <\/p>\n<p>\u6211\u4eec\u4ec5\u4ec5\u89e6\u53ca\u4e86\u8868\u9762\uff0c\u56e0\u4e3a\u8fd8\u6709\u5176\u4ed6\u4ee4\u4eba\u5174\u594b\u7684\u5168\u5c40\u53d8\u91cf\u53ef\u4ee5\u4f7f\u7528\uff1b\u4f46\u662f\uff0c\u8bf7\u8bb0\u4f4f\uff0c\u8981\u8bbf\u95ee\u5168\u5c40\u53d8\u91cf\u624d\u80fd<em>\u663e\u793a<\/em>\u503c\u3002\u5982\u679c\u6211\u4eec\u7be1\u6539\u5b83\u4eec\u5305\u542b\u7684\u503c\uff0c\u90a3\u4e48\u6211\u4eec\u5c31\u6709\u53ef\u80fd\u5bfc\u81f4\u4e0d\u53ef\u9884\u6d4b\u7684\u884c\u4e3a\u3002<\/p>\n<h2>\u4e0b\u4e00\u6b65\u662f\u4ec0\u4e48\uff1f<\/h2>\n<p>\u5728\u672c\u6b21\u4f1a\u8bae\u4e2d\uff0c\u6211\u4eec\u4e86\u89e3\u4e86\u5168\u5c40\u53d8\u91cf\u4ee5\u53ca WordPress \u4e2d\u5b58\u5728\u7684\u8f83\u5e38\u89c1\u53d8\u91cf\u4e4b\u4e00\u7684\u57fa\u672c\u793a\u4f8b\u3002<\/p>\n<p>\u5728\u540e\u7eed\u6559\u7a0b\u4e2d\uff0c\u6211\u4eec\u5c06\u4e86\u89e3\u5982\u4f55\u4f7f\u7528author\u5168\u5c40\u53d8\u91cf\u6765\u4e86\u89e3\u6709\u5173WordPress\u5168\u5c40\u53d8\u91cf\u7684\u66f4\u591a\u4fe1\u606f\u3002<\/p>\n<p>\u4ee5\u4e0a\u5c31\u662f\u63a2\u7d22 WordPress \u5168\u5c40\u53d8\u91cf\uff1a\u521d\u5b66\u8005\u6307\u5357\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>\u5728\u8fd9\u4e2a\u7531\u4e09\u90e8\u5206\u7ec4\u6210\u7684\u7cfb\u5217\u4e2d\uff0c\u6211\u4eec\u5c06\u7814\u7a76 wordpress \u5168\u5c40\u53d8\u91cf\uff0c\u4ee5\u4fbf\u66f4\u597d\u5730\u4e86\u89e3\u5b83\u4eec\uff0c\u4ee5\u4fbf\u6211\u4eec\u53ef\u4ee5\u5c06\u5b83\u4eec\u5e94\u7528\u5230\u65e5\u5e38\u5f00\u53d1\u4e2d\u3002 \u5728\u6574\u4e2a\u7cfb\u5217\u4e2d\uff0c\u6211\u4eec\u5c06\u8fdb\u884c\u4e00\u7cfb\u5217\u5b9e\u8df5\u7ec3\u4e60\uff0c\u5c55\u793a\u5168\u5c40\u53d8\u91cf\u5728\u663e\u793a\u548c\u8c03\u6574 WordPress \u5185\u90e8\u5de5\u4f5c\u65b9\u9762\u7684\u5f3a\u5927\u529f\u80fd\u3002 \u4ec0\u4e48\u662f WordPress \u5168\u5c40\u53d8\u91cf\uff1f WordPress \u5168\u5c40\u53d8\u91cf\u662f\u4fdd\u5b58\u5e94\u7528\u7a0b\u5e8f\u751f\u6210\u7684\u4fe1\u606f\u7684\u53d8\u91cf\u3002\u53ef\u4ee5\u5728\u5e94\u7528\u7a0b\u5e8f\u6267\u884c\u671f\u95f4\u548c\u9875\u9762\u751f\u547d\u5468\u671f\u671f\u95f4\u8bbf\u95ee\u8fd9\u4e9b\u5168\u5c40\u53d8\u91cf\u3002 \u8fd9\u4e9b\u53d8\u91cf\u4fdd\u5b58\u5404\u79cd\u4fe1\u606f\uff0c\u4f8b\u5982\u7528\u6237\u662f\u5426\u767b\u5f55\u3001\u7528\u6237\u8bbf\u95ee\u7f51\u7ad9\u65f6\u4f7f\u7528\u7684\u6d4f\u89c8\u5668\u7b49\u7b49\u3002\u6709\u4e9b\u53d8\u91cf\u4fdd\u5b58 Web \u670d\u52a1\u5668\u7684\u8be6\u7ec6\u4fe1\u606f\uff0c\u8fd8\u6709\u4e00\u4e9b\u53d8\u91cf\u4fdd\u5b58\u5f53\u524d\u5e16\u5b50\u7684\u8be6\u7ec6\u4fe1\u606f\u3002\u53ef\u4ee5\u8bbf\u95ee\u5168\u5c40\u53d8\u91cf\u7684\u503c\u6765\u4e86\u89e3 WordPress \u7684\u5185\u90e8\u5de5\u4f5c\u539f\u7406\uff0c\u4ee5\u4fbf\u5f00\u59cb\u5728\u4e3b\u9898\u548c\u63d2\u4ef6\u4e2d\u5f15\u5165\u65b0\u529f\u80fd\u3002 \u6211\u4eec\u5982\u4f55\u8bbf\u95ee\u5168\u5c40\u53d8\u91cf\uff1f \u5728\u6211\u4eec\u7684\u7b2c\u4e00\u4e2a\u793a\u4f8b\u4e2d\uff0c\u6211\u4eec\u5c06\u4f7f\u7528 $post \u5168\u5c40\u53d8\u91cf\u6765\u4fdd\u5b58\u6709\u5173\u5f53\u524d\u5e16\u5b50\u6570\u636e\u7684\u5404\u79cd\u8be6\u7ec6\u4fe1\u606f\u3002 \u6bcf\u4e2a\u5168\u5c40\u53d8\u91cf\u90fd\u53ef\u4ee5\u901a\u8fc7\u5982\u4e0b\u65b9\u5f0f\u5168\u5c40\u5316\u53d8\u91cf\u6765\u8bbf\u95ee\uff1a&nbsp; &nbsp; &lt;?php global $post; ?&gt; \u767b\u5f55\u540e\u590d\u5236 \u901a\u8fc7\u4f7f\u7528 global \u5173\u952e\u5b57\uff0c\u6211\u4eec\u58f0\u660e\u6211\u4eec\u6b63\u5728\u8bbf\u95ee $post \u5168\u5c40\u53d8\u91cf\u3002\u4e00\u65e6\u53d8\u91cf\u88ab\u5168\u7403\u5316\uff0c\u53ef\u4ee5\u4f7f\u7528\u4ee5\u4e0b\u6e90\u4ee3\u7801\u68c0\u7d22\u53ef\u8bbf\u95ee\u7684\u5404\u79cd\u503c\uff1a &lt;?php global $post; print_r ($post ); \u767b\u5f55\u540e\u590d\u5236 $post&nbsp;\u5168\u5c40\u53d8\u91cf\u5305\u542b\u6709\u5173\u6700\u8fd1\u52a0\u8f7d\u7684\u5e16\u5b50\u7684\u5404\u79cd\u6570\u636e\u3002\u7ee7\u7eed\u5c06\u4e0a\u9762\u7684\u4ee3\u7801\u7247\u6bb5\u63d2\u5165\u5230\u4e8c\u5341\u56db\u4e3b\u9898\u7684 page.php \u4e2d\uff08\u5c3d\u7ba1\u6211\u5efa\u8bae\u5728\u8fdb\u884c\u8fd9\u4e9b\u66f4\u6539\u4e4b\u524d\u5907\u4efd\u4e3b\u9898\uff09\u3002 \u5c06\u4e0a\u9762\u7684\u4ee3\u7801\u7247\u6bb5\u7c98\u8d34\u5230 get_template_part( \u2018content\u2019, \u2018page\u2019 ) \u4e4b\u540e\uff0c\u5b83\u4f1a\u83b7\u53d6\u5185\u5bb9\u5e76\u5c06\u5176\u663e\u793a\u5728\u9875\u9762\u4e0a\u3002\u8fd9\u662f\u6211\u4eec\u5230\u76ee\u524d\u4e3a\u6b62\u5728 page.php \u4e0a\u5e94\u8be5\u62e5\u6709\u7684\u5185\u5bb9\uff1a &lt;div id=&#8221;primary&#8221; class=&#8221;content-area&#8221;&gt; &lt;div id=&#8221;content&#8221; [&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-32575","post","type-post","status-publish","format-standard","hentry","category-cms"],"_links":{"self":[{"href":"https:\/\/fwq.ai\/blog\/wp-json\/wp\/v2\/posts\/32575","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=32575"}],"version-history":[{"count":0,"href":"https:\/\/fwq.ai\/blog\/wp-json\/wp\/v2\/posts\/32575\/revisions"}],"wp:attachment":[{"href":"https:\/\/fwq.ai\/blog\/wp-json\/wp\/v2\/media?parent=32575"}],"wp:term":[{"taxonomy":"category","embeddable":true,"href":"https:\/\/fwq.ai\/blog\/wp-json\/wp\/v2\/categories?post=32575"},{"taxonomy":"post_tag","embeddable":true,"href":"https:\/\/fwq.ai\/blog\/wp-json\/wp\/v2\/tags?post=32575"}],"curies":[{"name":"wp","href":"https:\/\/api.w.org\/{rel}","templated":true}]}}