{"id":28949,"date":"2024-11-25T13:37:30","date_gmt":"2024-11-25T05:37:30","guid":{"rendered":"https:\/\/fwq.ai\/blog\/28949\/"},"modified":"2024-11-25T13:37:30","modified_gmt":"2024-11-25T05:37:30","slug":"wordpress%e6%96%87%e7%ab%a0%e5%88%97%e8%a1%a8%e6%80%8e%e4%b9%88%e8%b0%83","status":"publish","type":"post","link":"https:\/\/fwq.ai\/blog\/28949\/","title":{"rendered":"wordpress\u6587\u7ae0\u5217\u8868\u600e\u4e48\u8c03"},"content":{"rendered":"<blockquote><p>\n  \u6709\u56db\u79cd\u65b9\u6cd5\u53ef\u4ee5\u8c03\u6574 wordpress \u6587\u7ae0\u5217\u8868\uff1a\u4f7f\u7528\u4e3b\u9898\u9009\u9879\u3001\u4f7f\u7528\u63d2\u4ef6\uff08\u5982 post types order\u3001wp post list\u3001boxy stuff\uff09\u3001\u4f7f\u7528\u4ee3\u7801\uff08\u5728 functions.php \u6587\u4ef6\u4e2d\u6dfb\u52a0\u8bbe\u7f6e\uff09\u6216\u76f4\u63a5\u4fee\u6539 wordpress \u6570\u636e\u5e93\u3002\n<\/p><\/blockquote>\n<p><img decoding=\"async\" src=\"https:\/\/img.php.cn\/upload\/article\/202406\/05\/2024060502302364469.jpg\" class=\"aligncenter\" title=\"wordpress\u6587\u7ae0\u5217\u8868\u600e\u4e48\u8c03\u63d2\u56fe\" alt=\"wordpress\u6587\u7ae0\u5217\u8868\u600e\u4e48\u8c03\u63d2\u56fe\" \/><\/p>\n<p><strong>\u5982\u4f55\u8c03\u6574 WordPress \u6587\u7ae0\u5217\u8868<\/strong><\/p>\n<p>WordPress \u662f\u4e00\u4e2a\u6d41\u884c\u7684\u5185\u5bb9\u7ba1\u7406\u7cfb\u7edf\uff0c\u5b83\u5141\u8bb8\u7528\u6237\u8f7b\u677e\u521b\u5efa\u548c\u7ba1\u7406\u7f51\u7ad9\u3002\u8c03\u6574\u6587\u7ae0\u5217\u8868\u662f\u81ea\u5b9a\u4e49 WordPress \u7f51\u7ad9\u5916\u89c2\u548c\u611f\u89c9\u7684\u5173\u952e\u6b65\u9aa4\u3002<\/p>\n<p><strong>\u65b9\u6cd5 1\uff1a\u4f7f\u7528\u4e3b\u9898\u9009\u9879<\/strong><\/p>\n<p>\u4e00\u4e9b WordPress \u4e3b\u9898\u63d0\u4f9b\u4e86\u5185\u7f6e\u9009\u9879\u6765\u8c03\u6574\u6587\u7ae0\u5217\u8868\u3002\u8fd9\u4e9b\u9009\u9879\u901a\u5e38\u4f4d\u4e8e\u4e3b\u9898\u5b9a\u5236\u5668\u4e2d\u3002\u8981\u8bbf\u95ee\u5b83\uff0c\u8bf7\u8f6c\u5230\u201c\u5916\u89c2\u201d\u2192\u201c\u5b9a\u5236\u201d\u3002<\/p>\n<p>\u67e5\u627e\u201c\u6587\u7ae0\u5217\u8868\u8bbe\u7f6e\u201d\u6216\u7c7b\u4f3c\u7684\u9009\u9879\u3002\u5728\u8fd9\u91cc\uff0c\u60a8\u53ef\u4ee5\u914d\u7f6e\u4ee5\u4e0b\u8bbe\u7f6e\uff1a<\/p>\n<ul>\n<li>\u6587\u7ae0\u4e2a\u6570\uff1a\u6bcf\u9875\u8981\u663e\u793a\u7684\u6587\u7ae0\u6570\u91cf<\/li>\n<li>\u5143\u6570\u636e\uff1a\u8981\u663e\u793a\u7684\u6587\u7ae0\u5143\u6570\u636e\uff0c\u4f8b\u5982\u4f5c\u8005\u3001\u65e5\u671f\u548c\u7c7b\u522b<\/li>\n<li>\u7f29\u7565\u56fe\uff1a\u662f\u5426\u663e\u793a\u6587\u7ae0\u7f29\u7565\u56fe<\/li>\n<li>\u5e03\u5c40\uff1a\u6587\u7ae0\u5217\u8868\u7684\u5e03\u5c40\uff0c\u4f8b\u5982\u7f51\u683c\u6216\u5217\u8868\u89c6\u56fe<\/li>\n<\/ul>\n<p><strong>\u65b9\u6cd5 2\uff1a\u4f7f\u7528\u63d2\u4ef6<\/strong><\/p>\n<p>\u53ef\u4ee5\u4f7f\u7528 WordPress \u63d2\u4ef6\u8fdb\u4e00\u6b65\u81ea\u5b9a\u4e49\u6587\u7ae0\u5217\u8868\u3002\u8fd9\u91cc\u6709\u51e0\u4e2a\u63a8\u8350\u7684\u63d2\u4ef6\uff1a<\/p>\n<p><strong>Post Types Order<\/strong>\uff1a\u5141\u8bb8\u60a8\u6839\u636e\u81ea\u5b9a\u4e49\u987a\u5e8f\u91cd\u65b0\u6587\u7ae0\u5217\u8868\u3002<br \/><strong>WP Post List<\/strong>\uff1a\u63d0\u4f9b\u4e00\u7cfb\u5217\u9009\u9879\u6765\u521b\u5efa\u9ad8\u7ea7\u6587\u7ae0\u5217\u8868\uff0c\u5305\u62ec\u81ea\u5b9a\u4e49\u7b5b\u9009\u5668\u548c\u6392\u5e8f\u3002<br \/><strong>Boxy Stuff<\/strong>\uff1a\u4e00\u4e2a\u591a\u529f\u80fd\u63d2\u4ef6\uff0c\u63d0\u4f9b\u81ea\u5b9a\u4e49\u6587\u7ae0\u5217\u8868\u6846\u5c0f\u90e8\u4ef6\u548c\u6a21\u677f\u3002<\/p>\n<p>\u5b89\u88c5\u5e76\u6fc0\u6d3b\u63d2\u4ef6\u540e\uff0c\u6309\u7167\u63d2\u4ef6\u8bf4\u660e\u914d\u7f6e\u8bbe\u7f6e\u3002<\/p>\n<p><strong>\u65b9\u6cd5 3\uff1a\u4f7f\u7528\u4ee3\u7801<\/strong><\/p>\n<p>\u5982\u679c\u60a8\u5bf9 WordPress \u719f\u6089\uff0c\u53ef\u4ee5\u4f7f\u7528\u4ee3\u7801\u81ea\u5b9a\u4e49\u6587\u7ae0\u5217\u8868\u3002\u5728 functions.php \u6587\u4ef6\u4e2d\u6dfb\u52a0\u4ee5\u4e0b\u4ee3\u7801\uff1a<\/p>\n<pre>\/\/ \u8bbe\u7f6e\u6587\u7ae0\u6bcf\u9875\u6570\u91cf\nadd_action( 'pre_get_posts', 'custom_posts_per_page' );\nfunction custom_posts_per_page( $query ) {\n  if ( is_admin() || ! $query-&gt;is_main_query() ) {\n    return;\n  }\n\n  $query-&gt;set( 'posts_per_page', 10 );\n}<\/pre>\n<p> \u767b\u5f55\u540e\u590d\u5236 <\/p>\n<p>\u66ff\u6362 \u201c10\u201d \u4e3a\u60a8\u5e0c\u671b\u5728\u6bcf\u9875\u4e0a\u663e\u793a\u7684\u6587\u7ae0\u6570\u91cf\u3002<\/p>\n<p><strong>\u65b9\u6cd5 4\uff1a\u76f4\u63a5\u4fee\u6539\u6570\u636e\u5e93<\/strong><\/p>\n<p>\u5982\u679c\u4e0a\u8ff0\u65b9\u6cd5\u4e0d\u8d77\u4f5c\u7528\uff0c\u60a8\u53ef\u4ee5\u76f4\u63a5\u4fee\u6539 WordPress \u6570\u636e\u5e93\u3002\u4f7f\u7528 phpMyAdmin \u6216\u7c7b\u4f3c\u5de5\u5177\u8fde\u63a5\u5230\u6570\u636e\u5e93\u3002<\/p>\n<p>\u627e\u5230 wp_options \u8868\u5e76\u67e5\u627e\u540d\u4e3a posts_per_page \u7684\u884c\u3002\u5c06\u503c\u66f4\u6539\u4e3a\u60a8\u5e0c\u671b\u5728\u6bcf\u9875\u4e0a\u663e\u793a\u7684\u6587\u7ae0\u6570\u91cf\u3002<\/p>\n<p>\u4ee5\u4e0a\u5c31\u662f\u6587\u7ae0\u5217\u8868\u600e\u4e48\u8c03\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>\u6709\u56db\u79cd\u65b9\u6cd5\u53ef\u4ee5\u8c03\u6574 wordpress \u6587\u7ae0\u5217\u8868\uff1a\u4f7f\u7528\u4e3b\u9898\u9009\u9879\u3001\u4f7f\u7528\u63d2\u4ef6\uff08\u5982 post types order\u3001wp post list\u3001boxy stuff\uff09\u3001\u4f7f\u7528\u4ee3\u7801\uff08\u5728 functions.php \u6587\u4ef6\u4e2d\u6dfb\u52a0\u8bbe\u7f6e\uff09\u6216\u76f4\u63a5\u4fee\u6539 wordpress \u6570\u636e\u5e93\u3002 \u5982\u4f55\u8c03\u6574 WordPress \u6587\u7ae0\u5217\u8868 WordPress \u662f\u4e00\u4e2a\u6d41\u884c\u7684\u5185\u5bb9\u7ba1\u7406\u7cfb\u7edf\uff0c\u5b83\u5141\u8bb8\u7528\u6237\u8f7b\u677e\u521b\u5efa\u548c\u7ba1\u7406\u7f51\u7ad9\u3002\u8c03\u6574\u6587\u7ae0\u5217\u8868\u662f\u81ea\u5b9a\u4e49 WordPress \u7f51\u7ad9\u5916\u89c2\u548c\u611f\u89c9\u7684\u5173\u952e\u6b65\u9aa4\u3002 \u65b9\u6cd5 1\uff1a\u4f7f\u7528\u4e3b\u9898\u9009\u9879 \u4e00\u4e9b WordPress \u4e3b\u9898\u63d0\u4f9b\u4e86\u5185\u7f6e\u9009\u9879\u6765\u8c03\u6574\u6587\u7ae0\u5217\u8868\u3002\u8fd9\u4e9b\u9009\u9879\u901a\u5e38\u4f4d\u4e8e\u4e3b\u9898\u5b9a\u5236\u5668\u4e2d\u3002\u8981\u8bbf\u95ee\u5b83\uff0c\u8bf7\u8f6c\u5230\u201c\u5916\u89c2\u201d\u2192\u201c\u5b9a\u5236\u201d\u3002 \u67e5\u627e\u201c\u6587\u7ae0\u5217\u8868\u8bbe\u7f6e\u201d\u6216\u7c7b\u4f3c\u7684\u9009\u9879\u3002\u5728\u8fd9\u91cc\uff0c\u60a8\u53ef\u4ee5\u914d\u7f6e\u4ee5\u4e0b\u8bbe\u7f6e\uff1a \u6587\u7ae0\u4e2a\u6570\uff1a\u6bcf\u9875\u8981\u663e\u793a\u7684\u6587\u7ae0\u6570\u91cf \u5143\u6570\u636e\uff1a\u8981\u663e\u793a\u7684\u6587\u7ae0\u5143\u6570\u636e\uff0c\u4f8b\u5982\u4f5c\u8005\u3001\u65e5\u671f\u548c\u7c7b\u522b \u7f29\u7565\u56fe\uff1a\u662f\u5426\u663e\u793a\u6587\u7ae0\u7f29\u7565\u56fe \u5e03\u5c40\uff1a\u6587\u7ae0\u5217\u8868\u7684\u5e03\u5c40\uff0c\u4f8b\u5982\u7f51\u683c\u6216\u5217\u8868\u89c6\u56fe \u65b9\u6cd5 2\uff1a\u4f7f\u7528\u63d2\u4ef6 \u53ef\u4ee5\u4f7f\u7528 WordPress \u63d2\u4ef6\u8fdb\u4e00\u6b65\u81ea\u5b9a\u4e49\u6587\u7ae0\u5217\u8868\u3002\u8fd9\u91cc\u6709\u51e0\u4e2a\u63a8\u8350\u7684\u63d2\u4ef6\uff1a Post Types Order\uff1a\u5141\u8bb8\u60a8\u6839\u636e\u81ea\u5b9a\u4e49\u987a\u5e8f\u91cd\u65b0\u6587\u7ae0\u5217\u8868\u3002WP Post List\uff1a\u63d0\u4f9b\u4e00\u7cfb\u5217\u9009\u9879\u6765\u521b\u5efa\u9ad8\u7ea7\u6587\u7ae0\u5217\u8868\uff0c\u5305\u62ec\u81ea\u5b9a\u4e49\u7b5b\u9009\u5668\u548c\u6392\u5e8f\u3002Boxy Stuff\uff1a\u4e00\u4e2a\u591a\u529f\u80fd\u63d2\u4ef6\uff0c\u63d0\u4f9b\u81ea\u5b9a\u4e49\u6587\u7ae0\u5217\u8868\u6846\u5c0f\u90e8\u4ef6\u548c\u6a21\u677f\u3002 \u5b89\u88c5\u5e76\u6fc0\u6d3b\u63d2\u4ef6\u540e\uff0c\u6309\u7167\u63d2\u4ef6\u8bf4\u660e\u914d\u7f6e\u8bbe\u7f6e\u3002 \u65b9\u6cd5 3\uff1a\u4f7f\u7528\u4ee3\u7801 \u5982\u679c\u60a8\u5bf9 WordPress \u719f\u6089\uff0c\u53ef\u4ee5\u4f7f\u7528\u4ee3\u7801\u81ea\u5b9a\u4e49\u6587\u7ae0\u5217\u8868\u3002\u5728 functions.php \u6587\u4ef6\u4e2d\u6dfb\u52a0\u4ee5\u4e0b\u4ee3\u7801\uff1a \/\/ \u8bbe\u7f6e\u6587\u7ae0\u6bcf\u9875\u6570\u91cf add_action( &#8216;pre_get_posts&#8217;, &#8216;custom_posts_per_page&#8217; ); [&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-28949","post","type-post","status-publish","format-standard","hentry","category-cms"],"_links":{"self":[{"href":"https:\/\/fwq.ai\/blog\/wp-json\/wp\/v2\/posts\/28949","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=28949"}],"version-history":[{"count":0,"href":"https:\/\/fwq.ai\/blog\/wp-json\/wp\/v2\/posts\/28949\/revisions"}],"wp:attachment":[{"href":"https:\/\/fwq.ai\/blog\/wp-json\/wp\/v2\/media?parent=28949"}],"wp:term":[{"taxonomy":"category","embeddable":true,"href":"https:\/\/fwq.ai\/blog\/wp-json\/wp\/v2\/categories?post=28949"},{"taxonomy":"post_tag","embeddable":true,"href":"https:\/\/fwq.ai\/blog\/wp-json\/wp\/v2\/tags?post=28949"}],"curies":[{"name":"wp","href":"https:\/\/api.w.org\/{rel}","templated":true}]}}