{"id":97617,"date":"2026-08-29T21:49:26","date_gmt":"2026-08-29T13:49:26","guid":{"rendered":"https:\/\/www.wsisp.com\/helps\/97617.html"},"modified":"2026-08-29T21:49:26","modified_gmt":"2026-08-29T13:49:26","slug":"wordpress-sql-%e6%b3%a8%e5%85%a5%e6%bc%8f%e6%b4%9e%e5%88%86%e6%9e%90%ef%bc%9a%e4%bb%8e-author__not_in-%e5%8f%82%e6%95%b0%e5%88%b0-rest-api-%e5%85%a8%e9%93%be%e8%b7%af","status":"publish","type":"post","link":"https:\/\/www.wsisp.com\/helps\/97617.html","title":{"rendered":"WordPress SQL \u6ce8\u5165\u6f0f\u6d1e\u5206\u6790\uff1a\u4ece author__not_in \u53c2\u6570\u5230 REST API \u5168\u94fe\u8def"},"content":{"rendered":"<p>\u6458\u8981&#xff1a;\u672c\u6587\u57fa\u4e8e WordPress 7.0.1 \u6e90\u7801&#xff0c;\u5b8c\u6574\u68b3\u7406\u4e86\u4e00\u6761 SQL \u6ce8\u5165\u6f0f\u6d1e\u7684\u5f62\u6210\u4e0e\u5229\u7528\u94fe\u8def&#xff1a;author__not_in \u53c2\u6570\u5728 WP_Query \u4e2d\u88ab\u62fc\u5165 post_author NOT IN (&#8230;)&#xff0c;\u800c\u5f00\u53d1\u8005\u4ec5\u7528 is_array() \u505a\u4e86\u5b89\u5168\u68c0\u67e5&#xff0c;\u5bfc\u81f4\u5b57\u7b26\u4e32\u7c7b\u578b\u7684\u8f93\u5165\u53ef\u4ee5\u7ed5\u8fc7 absint() \u5f3a\u5236\u6574\u6570\u8f6c\u6362&#xff0c;\u539f\u59cb\u6076\u610f\u5b57\u7b26\u4e32\u76f4\u63a5\u8fdb\u5165 SQL\u3002\u4e3a\u8bf4\u660e\u653b\u51fb\u8005\u5982\u4f55\u8ba9\u5185\u90e8\u53c2\u6570\u63a5\u6536\u5916\u90e8\u8f93\u5165&#xff0c;\u6587\u7ae0\u8fdb\u4e00\u6b65\u5206\u6790 GET \/wp\/v2\/posts \u8def\u7531\u4ece\u6ce8\u518c\u3001\u53c2\u6570\u6620\u5c04\u5230 WP_REST_Posts_Controller::get_items() \u8c03\u7528 WP_Query \u7684\u5b8c\u6574\u8fc7\u7a0b&#xff0c;\u6253\u901a\u201cHTTP \u8bf7\u6c42 \u2192 REST API \u2192 WP_Query \u2192 SQL \u6267\u884c\u201d\u7684\u6570\u636e\u6d41\u3002<\/p>\n<p><span style=\"color:#fe2c24\">\u7531\u4e8e\u4e2a\u4eba\u6c34\u5e73\u6709\u9650&#xff0c;\u6587\u4e2d\u82e5\u6709\u4e0d\u8db3\u4e4b\u5904&#xff0c;\u6b22\u8fce\u6279\u8bc4\u6307\u6b63\u3002<\/span><\/p>\n<h2 style=\"margin-left:0px;text-align:justify\">sql\u6f0f\u6d1e\u600e\u4e48\u5f62\u6210\u7684<\/h2>\n<h2 style=\"margin-left:0px;text-align:justify\"><span style=\"color:black\">author__not_in <\/span><span style=\"color:black\">\u662f\u4ec0\u4e48&#xff1f;<\/span><\/h2>\n<p style=\"margin-left:0;text-align:justify\"><span style=\"color:black\">\u4ece\u6ce8\u91ca\u4fe1\u606f\u53ef\u4ee5\u5f97\u5230&#xff1a;author__not_in \u662f\u4e00\u4e2a\u4f5c\u8005<\/span><span style=\"color:black\"> ID <\/span><span style=\"color:black\">\u6570\u7ec4&#xff0c;\u8868\u793a\u8fd9\u4e9b\u4f5c\u8005\u7684\u6587\u7ae0\u4e0d\u8981\u67e5\u8be2 <\/span><img loading=\"lazy\" decoding=\"async\" alt=\"\" height=\"367\" src=\"https:\/\/www.wsisp.com\/helps\/wp-content\/uploads\/2026\/08\/20260829134922-6a92e3620c6ab.png\" width=\"1206\" \/><\/p>\n<p style=\"margin-left:0;text-align:justify\"><span style=\"color:black\">\u8fd9\u91cc\u628a<\/span><span style=\"color:black\">author__not_in<\/span><span style=\"color:black\">\u653e\u8fdb\u4e86 $array_keys&#xff0c;\u7d27\u63a5\u7740\u5728\u4e0b\u9762\u5982\u679c<\/span><span style=\"color:black\"> author__not_in <\/span><span style=\"color:black\">\u6ca1\u6709\u63d0\u4f9b&#xff0c;<\/span><span style=\"color:black\">WordPress <\/span><span style=\"color:black\">\u4f1a\u7ed9\u5b83\u4e00\u4e2a\u7a7a\u6570\u7ec4\u4f5c\u4e3a\u9ed8\u8ba4\u503c\u3002<\/span><\/p>\n<p style=\"margin-left:0;text-align:justify\"><span style=\"color:black\">$query_vars <\/span><span style=\"color:black\">\u662f<\/span><span style=\"color:black\">WordPress <\/span><span style=\"color:black\">\u5168\u5c40\u6570\u7ec4<\/span><\/p>\n<p><img loading=\"lazy\" decoding=\"async\" alt=\"\" height=\"580\" src=\"https:\/\/www.wsisp.com\/helps\/wp-content\/uploads\/2026\/08\/20260829134922-6a92e36246c01.png\" width=\"751\" \/><\/p>\n<h2 style=\"margin-left:0px;text-align:justify\">author__not_in\u600e\u4e48\u53d8\u6210 SQL\u8bed\u53e5<\/h2>\n<p>if ( ! empty( $query_vars[&#039;author__not_in&#039;] ) ) {<br \/>\nif ( is_array( $query_vars[&#039;author__not_in&#039;] ) ) {<br \/>\n$query_vars[&#039;author__not_in&#039;] &#061; array_unique(<br \/>\n                array_map(<br \/>\n                    &#039;absint&#039;, $query_vars[&#039;author__not_in&#039;]<br \/>\n                         )<br \/>\n                        );<br \/>\nsort( $query_vars[&#039;author__not_in&#039;] );<br \/>\n}<br \/>\n$author__not_in &#061; implode( &#039;,&#039;, (array) $query_vars[&#039;author__not_in&#039;] );<br \/>\n$where         .&#061; &#034; AND {$wpdb-&gt;posts}.post_author NOT IN ($author__not_in) &#034;;<br \/>\n} <\/p>\n<h3 style=\"margin-left:0px;text-align:justify\"><span style=\"color:black\">\u7b2c\u4e00\u6b65&#xff1a;\u5224\u65adauthor__not_in\u662f\u5426\u4e3a\u7a7a<\/span><\/h3>\n<p style=\"margin-left:0;text-align:justify\"><span style=\"color:black\">\u5982\u679c\u7528\u6237<\/span><span style=\"color:black\">\/<\/span><span style=\"color:black\">\u7a0b\u5e8f\u63d0\u4f9b\u4e86<\/span><span style=\"color:black\"> author__not_in<\/span><span style=\"color:black\">&#xff0c;\u5e76\u4e14\u5b83\u4e0d\u662f\u7a7a\u7684&#xff0c;\u5c31\u5904\u7406\u5b83\u3002\u4e8e\u662f\u8fdb\u5165\u8fd9\u4e2a<\/span><span style=\"color:black\"> if<\/span><\/p>\n<h3 style=\"margin-left:0px;text-align:justify\"><span style=\"color:#000000\">\u7b2c\u4e8c\u6b65&#xff1a;<\/span><span style=\"color:#000000\">\u68c0\u67e5\u4f20\u5165\u7684\u662f\u4e0d\u662f\u6570\u7ec4<\/span><\/h3>\n<p style=\"margin-left:0;text-align:justify\"><span style=\"color:black\">\u8fd9\u91cc\u975e\u5e38\u5173\u952e&#xff0c;\u56e0\u4e3a\u524d\u9762\u6211\u4eec\u5df2\u7ecf\u77e5\u9053&#xff1a;author__not_in\u8bbe\u8ba1\u4e0a\u5e94\u8be5\u662f&#xff1a;\u6570\u7ec4\u3002\u6240\u4ee5\u5f00\u53d1\u8005\u8fd9\u91cc\u8fdb\u4e00\u6b65\u68c0\u67e5&#xff1a;\u4f20\u8fdb\u6765\u7684\u4e1c\u897f\u5230\u5e95\u662f\u4e0d\u662f\u6570\u7ec4&#xff1f;\u5982\u679c\u662f&#xff1a;[1, 2, 3]&#xff0c;\u90a3\u4e48is_array(&#8230;)\u8fd4\u56de<\/span><span style=\"color:black\">true\u3002\u8fdb\u5165\u4e0b\u9762\u3002<\/span><\/p>\n<h3 style=\"margin-left:0px;text-align:justify\">\u7b2c\u4e09\u6b65&#xff1a;<span style=\"color:black\">\u771f\u5b9e\u4ee3\u7801\u4e2d\u7684<\/span><span style=\"color:black\"> absint()<\/span><\/h3>\n<p><img loading=\"lazy\" decoding=\"async\" alt=\"\" height=\"472\" src=\"https:\/\/www.wsisp.com\/helps\/wp-content\/uploads\/2026\/08\/20260829134922-6a92e362647a0.png\" width=\"1196\" \/><\/p>\n<p><img loading=\"lazy\" decoding=\"async\" alt=\"\" height=\"179\" src=\"https:\/\/www.wsisp.com\/helps\/wp-content\/uploads\/2026\/08\/20260829134922-6a92e362a1250.png\" width=\"552\" \/><\/p>\n<p><img loading=\"lazy\" decoding=\"async\" alt=\"\" height=\"761\" src=\"https:\/\/www.wsisp.com\/helps\/wp-content\/uploads\/2026\/08\/20260829134922-6a92e362b7626.png\" width=\"604\" \/><\/p>\n<p>absint()\u5f3a\u5236\u7c7b\u578b\u8f6c\u6362&#xff0c;\u628a\u4f20\u5165\u53d8\u91cf\u5f3a\u884c\u53d8\u6210\u6574\u6570<\/p>\n<p><img loading=\"lazy\" decoding=\"async\" alt=\"\" height=\"176\" src=\"https:\/\/www.wsisp.com\/helps\/wp-content\/uploads\/2026\/08\/20260829134922-6a92e362d6cdb.png\" width=\"565\" \/><\/p>\n<p style=\"margin-left:0;text-align:justify\"><span style=\"color:black\">\u6240\u4ee5\u8fd9\u91cc\u7684\u539f\u672c\u4f5c\u7528\u5c31\u662f&#xff1a;<\/span><span style=\"color:black\">\u628a\u4f5c\u8005<\/span><span style=\"color:black\"> ID <\/span><span style=\"color:black\">\u6309\u6574\u6570\u5904\u7406\u3002<\/span><span style=\"color:black\">\u7136\u540earray_unique()\u53bb\u9664\u91cd\u590d\u503c\u3002\u6700\u540e&#xff1a;sort()\u6392\u5e8f\u3002<\/span><\/p>\n<p style=\"margin-left:0;text-align:justify\">\n<h3 style=\"margin-left:0px;text-align:justify\">\u7b2c\u56db\u6b65&#xff1a;\u628a\u6570\u7ec4\u8f6c\u6362\u6210 SQL \u4e2d\u9700\u8981\u7684\u9017\u53f7\u5206\u9694\u5b57\u7b26\u4e32\u3002<\/h3>\n<p><img loading=\"lazy\" decoding=\"async\" alt=\"\" height=\"188\" src=\"https:\/\/www.wsisp.com\/helps\/wp-content\/uploads\/2026\/08\/20260829134922-6a92e362ed1a3.png\" width=\"437\" \/><\/p>\n<p><img loading=\"lazy\" decoding=\"async\" alt=\"\" height=\"643\" src=\"https:\/\/www.wsisp.com\/helps\/wp-content\/uploads\/2026\/08\/20260829134923-6a92e3630ec97.png\" width=\"866\" \/><\/p>\n<p>$author__not_in &#061; implode( &#039;,&#039;, (array) $query_vars[&#039;author__not_in&#039;] );<\/p>\n<p>&#xff08;arrary&#xff09;\u628a\u53d8\u91cf\u5f3a\u5236\u8f6c\u6362\u4e3a\u6570\u7ec4<\/p>\n<p>\u6bd4\u5982&#xff1a;[1, 2, 3]\u7ecf\u8fc7&#xff1a;implode(&#039;,&#039;, [1,2,3])&#xff0c;\u5f97\u5230&#xff1a;1,2,3\u3002\u4e8e\u662f&#xff1a;$author__not_in\u73b0\u5728\u5c31\u662f&#xff1a;&#034;1,2,3&#034;<\/p>\n<h3 style=\"margin-left:0px;text-align:justify\"><span style=\"color:black\">\u7b2c\u4e94\u6b65&#xff1a;\u771f\u6b63\u8fdb\u5165<\/span><span style=\"color:black\"> SQL\u67e5\u8be2<\/span><\/h3>\n<p style=\"margin-left:0;text-align:justify\"><span style=\"color:black\">\u7136\u540e\u5c31\u662f\u6700\u5173\u952e\u7684\u4e00\u884c&#xff1a;<\/span><\/p>\n<p style=\"margin-left:0;text-align:justify\"><span style=\"color:black\">$wpdb&#xff1a;<\/span><span style=\"color:black\">WordPress <\/span><span style=\"color:black\">\u5168\u5c40\u6570\u636e\u5e93\u5bf9\u8c61<\/span><span style=\"color:black\">&#xff0c;$wpdb-&gt;posts \u2192 \u5b58\u50a8\u6587\u7ae0\u7684\u8868\u540d&#xff0c;\u5e26\u8868\u524d\u7f00\u3002<\/span><\/p>\n<p style=\"margin-left:0;text-align:justify\"><span style=\"color:black\">\u793a\u4f8b&#xff1a;$sql &#061; &#034;SELECT * FROM {$wpdb-&gt;posts} WHERE ID&#061;1&#034;<\/span><\/p>\n<p>\u6267\u884c\u540e&#xff0c;\u5b57\u7b26\u4e32\u88ab\u89e3\u6790\u6210&#xff1a;SELECT * FROM wp_posts WHERE ID&#061;1<\/p>\n<p>\u56de\u5230\u672c\u6587\u7684\u73af\u5883\u4e2d<\/p>\n<p>$where .&#061; &#034; AND {$wpdb-&gt;posts}.post_author NOT IN ($author__not_in) &#034;;<\/p>\n<p style=\"margin-left:0;text-align:justify\"><span style=\"color:black\">\u539f\u672c\u7a0b\u5e8f\u5199\u7684\u662f&#xff1a;post_author NOT IN (&#8230;)\u3002\u800c&#xff1a;$author__not_in\u4f1a\u88ab\u653e\u8fdb\u53bb\u3002<\/span><\/p>\n<p style=\"margin-left:0;text-align:justify\"><span style=\"color:black\">\u6b63\u5e38\u60c5\u51b5\u4e0b&#xff1a;$author__not_in &#061; &#034;1,2,3&#034;\u4e8e\u662f&#xff1a;post_author NOT IN (1,2,3)\u8fd9\u5b8c\u5168\u7b26\u5408\u9884\u671f\u3002<\/span><\/p>\n<h3 style=\"background-color:transparent;margin-left:0px;text-align:justify\">sql\u6f0f\u6d1e\u5230\u5e95\u5728\u54ea\u91cc&#xff1f;<\/h3>\n<p>\u5173\u952e\u95ee\u9898\u5728\u4e8e&#xff1a;<\/p>\n<p style=\"margin-left:0;text-align:justify\"><span style=\"color:black\">if ( is_array( $query_vars[&#039;author__not_in&#039;] ) )\u53ea\u6709\u6570\u7ec4\u624d\u6267\u884c absint()<\/span><span style=\"color:black\">\u3002<\/span><\/p>\n<p style=\"margin-left:0;text-align:justify\"><span style=\"color:black\">\u5982\u679c\u8fd9\u4e2a\u53d8\u91cf\u5728\u8fdb\u5165\u8fd9\u91cc\u7684\u65f6\u5019\u662fstring&#xff0c;\u90a3\u4e48is_array(&#8230;)\u5c31\u662ffalse\u4e8e\u662f&#xff1a;array_map(&#039;absint&#039;, &#8230;)\u6839\u672c\u4e0d\u6267\u884c\u3002<\/span><\/p>\n<p style=\"margin-left:0;text-align:justify\"><span style=\"color:black\">\u603b\u7ed3&#xff1a;is_array() <\/span><span style=\"color:black\">\u6210\u4e3a\u4e86\u5b89\u5168\u5904\u7406\u7684\u6761\u4ef6&#xff0c;\u800c\u975e\u6570\u7ec4\u8f93\u5165\u53ef\u4ee5\u7ed5\u8fc7\u8fd9\u4e2a\u6761\u4ef6&#xff1b;\u540e\u7eed<\/span><span style=\"color:black\"> (array) <\/span><span style=\"color:black\">\u53ea\u662f\u7c7b\u578b\u8f6c\u6362&#xff0c;\u4e0d\u662f\u5b89\u5168\u6821\u9a8c&#xff0c;\u6700\u7ec8\u539f\u59cb\u5b57\u7b26\u4e32\u8fdb\u5165\u4e86<\/span><span style=\"color:black\"> SQL <\/span><span style=\"color:black\">\u62fc\u63a5\u3002<\/span><\/p>\n<p>\u6b63\u5e38\u60c5\u51b5&#xff1a;[1,2,3]\u6700\u540e\u53d8\u6210NOT IN (1,2,3)<\/p>\n<p>\u6f0f\u6d1e\u60c5\u51b5&#xff1a;\u53d8\u6210NOT IN (lastname,123)<img loading=\"lazy\" decoding=\"async\" alt=\"\" height=\"229\" src=\"https:\/\/www.wsisp.com\/helps\/wp-content\/uploads\/2026\/08\/20260829134923-6a92e36342ee0.png\" width=\"1172\" \/><\/p>\n<\/p>\n<h2>\u6f0f\u6d1e\u662f\u600e\u4e48\u88ab\u5229\u7528<\/h2>\n<p>\u9996\u5148\u601d\u8003\u7684\u662f\u653b\u51fb\u8005\u5b9e\u9645\u4e0a\u662f\u600e\u4e48\u628a\u8fd9\u4e2a\u201c\u672c\u6765\u53ea\u80fd\u63a5\u6536\u6570\u7ec4\u7684\u5185\u90e8\u53c2\u6570\u201d&#xff0c;\u53d8\u6210\u4e00\u4e2a\u53ef\u63a7\u5b57\u7b26\u4e32&#xff0c;\u5e76\u8ba9\u5b83\u8fdb\u5165 SQL \u7684&#xff1f;<\/p>\n<p>\u653b\u51fb\u8005\u771f\u6b63\u9700\u8981\u89e3\u51b3\u7684\u95ee\u9898\u5176\u5b9e\u53ea\u6709\u4e00\u4e2a&#xff1a;<\/p>\n<p>\u600e\u4e48\u8ba9 author__not_in \u4ee5\u5b57\u7b26\u4e32\u5f62\u5f0f\u5230\u8fbe\u8fd9\u91cc&#xff1f;<\/p>\n<p>\u56e0\u4e3a\u5982\u679c\u76f4\u63a5\u4f20&#xff1a;author__not_in &#061; [\u653b\u51fb\u8005\u6570\u636e]&#xff0c;\u5b83\u662f\u6570\u7ec4&#xff0c;\u653b\u51fb\u8005\u7684\u6570\u636e\u5c31\u4f1a\u88ab\u8f6c\u6362\u6210\u6574\u6570\u3002<\/p>\n<p>\u6240\u4ee5&#xff1a;\u8fd9\u5c31\u662f\u4e3a\u4ec0\u4e48\u4e0d\u80fd\u7b80\u5355\u7406\u89e3\u6210\u201c\u627e\u5230 SQL \u62fc\u63a5\u70b9\u7136\u540e\u4f20 Payload\u201d\u3002<\/p>\n<\/p>\n<h2>\u4ec0\u4e48\u662f REST API&#xff1f;<\/h2>\n<h3>1. API \u662f\u4ec0\u4e48<\/h3>\n<p>API \u53ef\u4ee5\u7b80\u5355\u7406\u89e3\u6210&#xff1a;\u7a0b\u5e8f\u548c\u7a0b\u5e8f\u4e4b\u95f4\u5bf9\u8bdd\u3001\u62ff\u6570\u636e\u3001\u6267\u884c\u529f\u80fd\u7684\u901a\u9053\u3002<\/p>\n<p>REST &#061; \u628a\u8d44\u6e90\u7684\u72b6\u6001&#xff0c;\u4ee5\u67d0\u79cd\u8868\u8ff0\u683c\u5f0f&#xff0c;\u5728\u5ba2\u6237\u7aef\u4e0e\u670d\u52a1\u7aef\u4e4b\u95f4\u8f6c\u79fb\u3002<\/p>\n<p>REST\u2011API&#xff1a;\u9075\u5faa REST \u8fd9\u5957\u8bbe\u8ba1\u98ce\u683c\u5199\u51fa\u6765\u7684 API \u63a5\u53e3\u3002<\/p>\n<p>\u53ef\u4ee5\u628a WordPress \u770b\u6210\u4e00\u4e2a\u7a0b\u5e8f\u3002\u6b63\u5e38\u60c5\u51b5\u4e0b&#xff1a;\u6d4f\u89c8\u5668\u8bbf\u95ee WordPress&#xff0c;WordPress \u8fd4\u56de HTML&#xff0c;\u8fd9\u662f\u7ed9\u4eba\/\u6d4f\u89c8\u5668\u770b\u7684\u3002\u4f46\u662f\u73b0\u5728\u5f88\u591a\u7a0b\u5e8f\u5e76\u4e0d\u9700\u8981 HTML\u3002\u6bd4\u5982&#xff1a;\u624b\u673a App\u3001\u524d\u7aef JavaScript\u3001WordPress \u533a\u5757\u7f16\u8f91\u5668\u3001\u5176\u4ed6\u7a0b\u5e8f\u5b83\u4eec\u66f4\u5e0c\u671b\u5f97\u5230&#xff1a;<\/p>\n<p>{<br \/>\n    &#034;id&#034;: 123,<br \/>\n    &#034;title&#034;: &#034;&#8230;&#034;,<br \/>\n    &#034;author&#034;: 1<br \/>\n}<\/p>\n<p>\u6240\u4ee5 WordPress \u63d0\u4f9b\u4e86\u4e00\u4e2a\u4e13\u95e8\u7684\u63a5\u53e3&#xff1a;<\/p>\n<p>WordPress REST API<\/p>\n<p>\u5b98\u65b9\u6587\u6863\u5bf9\u5b83\u7684\u5b9a\u4e49\u5c31\u662f&#xff1a;\u5b83\u63d0\u4f9b\u4e00\u4e2a\u63a5\u53e3&#xff0c;\u8ba9\u5e94\u7528\u901a\u8fc7 HTTP \u4e0e WordPress \u7ad9\u70b9\u4ea4\u4e92&#xff0c;\u5e76\u4ee5 JSON \u5f62\u5f0f\u4ea4\u6362\u6570\u636e\u3002<\/p>\n<hr \/>\n<h3>2. \u4e3a\u4ec0\u4e48 WordPress \u9700\u8981 REST API&#xff1f;<\/h3>\n<p>\u8fd9\u4e2a\u95ee\u9898\u975e\u5e38\u91cd\u8981\u3002\u4e0d\u662f\u56e0\u4e3a\u201c\u6f0f\u6d1e\u9700\u8981 REST API\u201d&#xff0c;\u800c\u662f&#xff1a;<\/p>\n<p>REST API \u672c\u6765\u5c31\u662f WordPress \u6b63\u5e38\u529f\u80fd\u7684\u4e00\u90e8\u5206\u3002<\/p>\n<p>WordPress \u9700\u8981\u8ba9\u5176\u4ed6\u7a0b\u5e8f\u80fd\u591f&#xff1a;\u8bfb\u53d6\u6587\u7ae0\u3001\u8bfb\u53d6\u9875\u9762\u3001\u8bfb\u53d6\u7528\u6237\u3001\u521b\u5efa\u6587\u7ae0\u3001\u4fee\u6539\u6587\u7ae0\u3001\u5220\u9664\u6587\u7ae0\u3002\u6240\u4ee5\u5b83\u63d0\u4f9b\u4e86\u4e00\u5957\u6807\u51c6 HTTP \u63a5\u53e3\u3002<\/p>\n<p>\u4f8b\u5982 WordPress \u5b98\u65b9 API \u4e2d&#xff1a;<span style=\"background-color:#ffd900\">\/wp\/v2\/posts\u5bf9\u5e94\u6587\u7ae0<\/span>\u3002\/wp\/v2\/users\u5bf9\u5e94\u7528\u6237\u3002\/wp\/v2\/pages\u5bf9\u5e94\u9875\u9762\u3002\u8fd9\u4e9b\u90fd\u662f WordPress REST API \u7684\u8d44\u6e90\u8def\u7531\u3002<\/p>\n<p>\u4f8b\u5982 WordPress \u7684 Posts&#xff1a;<\/p>\n<p>GET<br \/>\n\/wp\/v2\/posts<\/p>\n<p>\u610f\u601d\u662f&#xff1a;\u83b7\u53d6\u6587\u7ae0\u5217\u8868\u3002<span style=\"background-color:#ffd900\">WordPress \u5b98\u65b9\u6587\u6863\u660e\u786e\u628a&#xff1a;GET \/wp\/v2\/posts\u5b9a\u4e49\u4e3a\u83b7\u53d6 Posts \u96c6\u5408\u7684\u63a5\u53e3<\/span><\/p>\n<hr \/>\n<h3>3. \u8fd9\u91cc\u7684 posts \u662f\u4ec0\u4e48&#xff1f;<\/h3>\n<p>\u8fd9\u4e2a\u5c31\u548c\u6f0f\u6d1e\u76f4\u63a5\u5f00\u59cb\u4ea7\u751f\u5173\u7cfb\u4e86\u3002<\/p>\n<p>WordPress \u91cc\u9762\u6709\u4e00\u4e2a\u975e\u5e38\u91cd\u8981\u7684\u6570\u636e\u7c7b\u578b&#xff1a;Post\u4e5f\u5c31\u662f\u6587\u7ae0\u3002REST API \u628a WordPress \u4e2d\u7684\u6587\u7ae0\u4f5c\u4e3a\u4e00\u4e2a\u8d44\u6e90\u66b4\u9732\u51fa\u6765\u3002<\/p>\n<p>\u6240\u4ee5\/wp\/v2\/posts\u5c31\u662f&#xff1a;<span style=\"color:black\">\u7531<\/span><span style=\"color:black\"> WordPress REST API v2 <\/span><span style=\"color:black\">\u7248\u672c\u63a5\u53e3\u524d\u7f00&#xff0c;\u6307\u5411<\/span><span style=\"color:black\"> posts <\/span><span style=\"color:black\">\u8d44\u6e90&#xff08;\u6587\u7ae0\u96c6\u5408&#xff09;&#xff0c;\u6620\u5c04\u6570\u636e\u5e93<\/span><span style=\"color:black\"> wp_posts <\/span><span style=\"color:black\">\u6587\u7ae0\u8868<\/span><\/p>\n<p style=\"margin-left:0;text-align:justify\"><span style=\"color:black\">URL <\/span><span style=\"color:black\">\u5206\u6bb5&#xff1a;<\/span><\/p>\n<p style=\"margin-left:0;text-align:justify\"><span style=\"color:black\">\/wp\/v2\/<\/span><span style=\"color:black\">&#xff1a;\u6807\u8bc6<\/span><span style=\"color:black\"> WordPress <\/span><span style=\"color:black\">\u7a0b\u5e8f&#xff0c;\u6307\u5b9a\u63a5\u53e3\u7248\u672c<\/span><span style=\"color:black\"> 2<\/span><span style=\"color:black\">&#xff0c;\u4f5c\u4e3a<\/span><span style=\"color:black\"> REST API <\/span><span style=\"color:black\">\u6839\u8def\u5f84&#xff0c;\u7528\u6765\u533a\u5206\u666e\u901a\u7f51\u9875\u8bbf\u95ee<\/span><span style=\"color:black\"> <\/span><\/p>\n<p style=\"margin-left:0;text-align:justify\"><span style=\"color:black\">\/posts<\/span><span style=\"color:black\">&#xff1a;\u547d\u540d\u8d44\u6e90<\/span><span style=\"color:black\"> posts<\/span><span style=\"color:black\">&#xff0c;\u4ee3\u8868\u6587\u7ae0\u96c6\u5408&#xff1b;<\/span><span style=\"color:black\">REST <\/span><span style=\"color:black\">\u98ce\u683c\u628a\u8d44\u6e90\u540d\u79f0\u5199\u5728\u8def\u5f84\u4e2d&#xff0c;\u4e0d\u4f7f\u7528&#xff1f;<\/span><span style=\"color:black\">action&#061;xxx <\/span><span style=\"color:black\">\u5f62\u5f0f&#xff0c;\u5bf9\u5e94<\/span><span style=\"color:black\"> wp_posts <\/span><span style=\"color:black\">\u8868<\/span><\/p>\n<p style=\"margin-left:0;text-align:justify\"><span style=\"color:black\">HTTP <\/span><span style=\"color:black\">\u65b9\u6cd5\u8bed\u4e49&#xff1a;<\/span><span style=\"color:black\"> <\/span><\/p>\n<p style=\"margin-left:0;text-align:justify\"><span style=\"color:black\">GET \/wp\/v2\/posts<\/span><span style=\"color:black\">&#xff1a;\u901a\u8fc7\u8def\u5f84\u5b9a\u4f4d\u5168\u90e8\u6587\u7ae0\u8d44\u6e90&#xff0c;\u4f7f\u7528<\/span><span style=\"color:black\"> GET <\/span><span style=\"color:black\">\u6267\u884c\u83b7\u53d6\u64cd\u4f5c&#xff0c;\u8bfb\u53d6\u5168\u90e8\u6587\u7ae0&#xff0c;\u8fd4\u56de<\/span><span style=\"color:black\"> JSON <\/span><span style=\"color:black\">\u683c\u5f0f\u5217\u8868<\/span><\/p>\n<p style=\"margin-left:0;text-align:justify\">\n<p>\u56e0\u6b64&#xff0c;\u5f53\u7a0b\u5e8f\u8bf7\u6c42&#xff1a;GET \/wp-json\/wp\/v2\/posts\u65f6WordPress \u5c31\u9700\u8981&#xff1a;\u627e\u5230\u6587\u7ae0&#xff0c;\u7136\u540e\u628a\u6587\u7ae0\u6570\u636e\u8f6c\u6362\u6210 JSON \u8fd4\u56de\u3002\u5b98\u65b9\u6587\u6863\u4e5f\u660e\u786e\u8bf4\u660e&#xff0c;\u8fd9\u4e2a\u8bf7\u6c42\u5927\u81f4\u5bf9\u5e94 WordPress \u5185\u90e8\u7684 WP_Query\u3002\u8fd9\u4e00\u70b9\u5bf9\u7814\u7a76 SQL \u6ce8\u5165\u975e\u5e38\u91cd\u8981\u3002<\/p>\n<hr \/>\n<h3>4.\u4e3a\u4ec0\u4e48\u8fd9\u4e00\u70b9\u548c\u6211\u4eec\u7684 SQL \u6ce8\u5165\u6709\u5173&#xff1f;<\/h3>\n<p style=\"margin-left:0;text-align:justify\"><span style=\"color:black\">\u5728\u524d\u9762\u7684\u89e3\u91ca\u4e2d\u6211\u4eec\u5df2\u7ecf\u53ef\u4ee5\u77e5\u9053<\/span><span style=\"color:black\">author__not_in <\/span><span style=\"color:black\">\u6700\u7ec8\u4f1a\u5f71\u54cd\u6587\u7ae0\u67e5\u8be2\u7684<\/span><span style=\"color:black\"> SQL<\/span><span style=\"color:black\">\u3002\u4f46\u662f\u73b0\u5728\u95ee\u9898\u6765\u4e86&#xff1a;\u8c01\u4f1a\u8c03\u7528<\/span><span style=\"color:black\"> WP_Query<\/span><span style=\"color:black\">&#xff1f;\u6211\u4eec\u4e0d\u80fd\u51ed\u7a7a\u8bf4&#xff1a;<\/span><\/p>\n<p style=\"margin-left:0;text-align:justify\">\u53ea\u8981 HTTP \u4f20\u6765 author__not_in&#xff0c;\u5c31\u4e00\u5b9a\u81ea\u52a8\u4ea4\u7ed9 WP_Query \u5904\u7406\u3002 <span style=\"background-color:#ffd900\">\u9700\u8981\u786e\u8ba4<\/span><span style=\"background-color:#ffd900\">\u54ea\u6bb5\u4ee3\u7801\u4f1a\u63a5\u6536 HTTP \u53c2\u6570&#xff0c;\u5e76\u628a\u8fd9\u4e2a\u53c2\u6570\u4f20\u7ed9 WP_Query<\/span><span style=\"background-color:#ffd900\">&#xff0c;\u53ea\u6709\u4ee3\u7801\u505a\u4e86\u8fd9\u4e00\u6b65&#xff0c;\u94fe\u8def\u624d\u6210\u7acb<\/span>&#xff1b;\u5982\u679c\u6ca1\u6709\u4ee3\u7801\u505a\u53c2\u6570\u6620\u5c04&#xff0c;\u5373\u4f7f\u8bf7\u6c42\u5e26\u4e0a author__not_in&#xff0c;WP_Query \u4e5f\u63a5\u6536\u4e0d\u5230&#xff0c;\u4e0d\u4f1a\u4fee\u6539 SQL\u3002<\/p>\n<p><span style=\"color:black\">\u800c<\/span><span style=\"color:black\"> <span style=\"background-color:#ffd900\">\/wp\/v2\/posts <\/span><\/span><span style=\"color:black\"><span style=\"background-color:#ffd900\">\u6070\u597d\u5c31\u662f<\/span><\/span><span style=\"color:black\"><span style=\"background-color:#ffd900\"> WordPress <\/span><\/span><span style=\"color:black\"><span style=\"background-color:#ffd900\">\u5bf9\u5916\u63d0\u4f9b\u7684\u67e5\u8be2\u6587\u7ae0\u63a5\u53e3&#xff0c;\u8be5\u63a5\u53e3\u5185\u90e8\u5b9e\u73b0\u4e86\u8fd9\u5c42\u903b\u8f91<\/span>&#xff1a;\u8bfb\u53d6<\/span><span style=\"color:black\"> HTTP <\/span><span style=\"color:black\">\u4f20\u5165\u7684\u67e5\u8be2\u53c2\u6570&#xff0c;\u628a<\/span><span style=\"color:black\">author__not_in<\/span><span style=\"color:black\">\u8fd9\u7c7b\u53c2\u6570\u76f4\u63a5\u4f20\u9012\u7ed9<\/span><span style=\"color:black\">WP_Query<\/span><span style=\"color:black\">&#xff0c;\u518d\u7531<\/span><span style=\"color:black\">WP_Query<\/span><span style=\"color:black\">\u62fc\u63a5\u751f\u6210<\/span><span style=\"color:black\"> SQL <\/span><span style=\"color:black\">\u8bed\u53e5\u6267\u884c\u6570\u636e\u5e93\u67e5\u8be2&#xff0c;\u5b8c\u6574\u6253\u901a\u4ece<\/span><span style=\"color:black\"> HTTP <\/span><span style=\"color:black\">\u8bf7\u6c42\u5230<\/span><span style=\"color:black\"> SQL <\/span><span style=\"color:black\">\u6267\u884c\u7684\u6574\u6761\u94fe\u8def\u3002<\/span><\/p>\n<hr \/>\n<h3>5.\u5c0f\u603b\u7ed3<\/h3>\n<p style=\"margin-left:0;text-align:justify\"><span style=\"color:black\">\u76ee\u524d\u5df2\u7ecf\u77e5\u9053&#xff1a;<\/span><span style=\"color:black\"> WP_Query <\/span><span style=\"color:black\">\u7528\u6765\u67e5\u8be2<\/span><span style=\"color:black\"> WordPress <\/span><span style=\"color:black\">\u6587\u7ae0\u3002<\/span><span style=\"color:black\">\u800c REST API <\/span><span style=\"color:black\">\u63a5\u53e3<\/span><span style=\"color:black\"> GET \/wp\u2011json\/wp\/v2\/posts <\/span><span style=\"color:black\">\u7684\u4f5c\u7528&#xff0c;\u540c\u6837\u7528\u6765\u67e5\u8be2<\/span><span style=\"color:black\"> WordPress <\/span><span style=\"color:black\">\u6587\u7ae0\u3002<\/span><\/p>\n<p style=\"margin-left:0;text-align:justify\"><span style=\"color:black\">\u6240\u4ee5\u4e24\u8005\u4f1a\u4ea7\u751f\u8c03\u7528\u8054\u7cfb&#xff1a;<\/span><span style=\"color:black\"><span style=\"background-color:#ffd900\"> HTTP <\/span><\/span><span style=\"color:black\"><span style=\"background-color:#ffd900\">\u8bf7\u6c42\u53d1\u9001\u5230<\/span><\/span><span style=\"color:black\"><span style=\"background-color:#ffd900\"> WordPress REST API<\/span><\/span><span style=\"color:black\"><span style=\"background-color:#ffd900\">&#xff0c;\u63a5\u53e3\u6267\u884c<\/span><\/span><span style=\"color:black\"><span style=\"background-color:#ffd900\"> Posts <\/span><\/span><span style=\"color:black\"><span style=\"background-color:#ffd900\">\u8d44\u6e90\u67e5\u8be2\u64cd\u4f5c&#xff0c;\u5185\u90e8\u8c03\u7528<\/span><\/span><span style=\"color:black\"><span style=\"background-color:#ffd900\"> WP_Query<\/span><\/span><span style=\"color:black\"><span style=\"background-color:#ffd900\">&#xff0c;\u6700\u7ec8\u8bbf\u95ee\u6570\u636e\u5e93\u5b8c\u6210\u6570\u636e\u8bfb\u53d6\u3002<\/span><\/span><\/p>\n<p style=\"margin-left:0;text-align:justify\"><span style=\"color:black\">\u5b98\u65b9\u6587\u6863\u8bf4\u660e&#xff1a;<\/span><span style=\"color:black\"> GET \/wp\u2011json\/wp\/v2\/posts <\/span><span style=\"color:black\">\u5927\u81f4\u7b49\u4ef7\u4e8e\u4f7f\u7528<\/span><span style=\"color:black\"> WP_Query <\/span><span style=\"color:black\">\u83b7\u53d6\u6587\u7ae0\u96c6\u5408\u3002<\/span><\/p>\n<hr \/>\n<h3>6.<span style=\"color:black\">WP_Query\u662f\u4ec0\u4e48<\/span><\/h3>\n<p style=\"margin-left:0;text-align:justify\"><span style=\"color:black\">WP_Query <\/span><span style=\"color:black\">\u662f<\/span><span style=\"color:black\"> WordPress <\/span><span style=\"color:black\">\u5185\u7f6e\u7684\u6838\u5fc3<\/span><span style=\"color:black\"> PHP <\/span><span style=\"color:black\">\u7c7b<\/span><span style=\"color:black\">&#xff0c;\u6587\u4ef6\u4f4d\u4e8e&#xff1a;<\/span><span style=\"color:black\">wp\u2011includes\/class\u2011wp\u2011query.php\u3002<\/span><\/p>\n<p style=\"text-align:justify\"><span style=\"color:black\">\u4f5c\u7528&#xff1a;\u4e13\u95e8\u5c01\u88c5\u6587\u7ae0\u3001\u9875\u9762\u3001\u81ea\u5b9a\u4e49\u7c7b\u578b\u6570\u636e\u7684\u67e5\u8be2\u903b\u8f91&#xff0c;\u63a5\u6536\u4e00\u7ec4\u67e5\u8be2\u53c2\u6570&#xff0c;\u5185\u90e8\u81ea\u52a8\u62fc\u63a5 SQL&#xff0c;\u5411 MySQL \u6570\u636e\u5e93\u67e5\u8be2\u5185\u5bb9\u3002<\/span><\/p>\n<p style=\"text-align:justify\"><span style=\"color:black\">\u5173\u952e\u70b9<\/span><span style=\"color:black\"> WP_Query <\/span><span style=\"color:black\">\u672c\u8eab\u4e0d\u4f1a\u81ea\u52a8\u8bfb\u53d6<\/span><span style=\"color:black\"> HTTP <\/span><span style=\"color:black\">\u8bf7\u6c42\u53c2\u6570<\/span><span style=\"color:black\">\u3002<\/span> <span style=\"color:black\">\u53ea\u6709\u4e0a\u5c42\u4ee3\u7801\u4e3b\u52a8\u8bfb\u53d6<\/span><span style=\"color:black\"> HTTP <\/span><span style=\"color:black\">\u8f93\u5165&#xff0c;\u628a\u53c2\u6570\u4f20\u7ed9<\/span><span style=\"color:black\"> WP_Query <\/span><span style=\"color:black\">\u5b9e\u4f8b&#xff0c;\u53c2\u6570\u624d\u4f1a\u751f\u6548&#xff1b;<\/span><span style=\"color:black\">REST\u2011API <\/span><span style=\"color:black\">\u63a5\u53e3\u5185\u90e8\u5c31\u505a\u4e86\u8fd9\u4e00\u6b65\u53c2\u6570\u642c\u8fd0&#xff0c;\u6240\u4ee5\u5916\u90e8<\/span><span style=\"color:black\"> HTTP <\/span><span style=\"color:black\">\u53c2\u6570\u53ef\u4ee5\u5f71\u54cd<\/span><span style=\"color:black\"> SQL<\/span><span style=\"color:black\">\u3002<\/span><\/p>\n<hr \/>\n<p style=\"margin-left:0;text-align:justify\"><span style=\"color:black\">\u4e5f\u5c31\u662f\u8bf4WP_Query <\/span><span style=\"color:black\">\u5c5e\u4e8e<\/span><span style=\"color:black\"> WordPress <\/span><span style=\"color:black\">\u7684\u5185\u90e8\u67e5\u8be2\u673a\u5236\u3002<\/span> <span style=\"color:black\">\u653b\u51fb\u8005\u53ea\u80fd\u53d1\u8d77<\/span><span style=\"color:black\"> HTTP <\/span><span style=\"color:black\">\u8bf7\u6c42&#xff0c;\u65e0\u6cd5\u76f4\u63a5\u5728\u670d\u52a1\u5668<\/span><span style=\"color:black\"> PHP <\/span><span style=\"color:black\">\u4ee3\u7801\u91cc\u76f4\u63a5\u8d4b\u503c<\/span><span style=\"color:black\">$query_vars[&#039;author__not_in&#039;]<\/span><span style=\"color:black\">\u3002<\/span><\/p>\n<p style=\"margin-left:0;text-align:justify\"><span style=\"color:black\">\u653b\u51fb\u8005\u5fc5\u987b\u627e\u5230\u4e00\u6761\u53ef\u7528\u6570\u636e\u6d41&#xff1a;<\/span><span style=\"color:black\">HTTP <\/span><span style=\"color:black\">\u8bf7\u6c42\u6d41\u5165<\/span><span style=\"color:black\"> WordPress <\/span><span style=\"color:black\">\u67d0\u4e2a\u529f\u80fd\u6a21\u5757&#xff0c;\u518d\u7531\u8be5\u529f\u80fd\u6a21\u5757\u628a\u53c2\u6570\u4f20\u9012\u7ed9<\/span><span style=\"color:black\"> WP_Query<\/span><span style=\"color:black\">\u3002<\/span><\/p>\n<p style=\"margin-left:0;text-align:justify\"><span style=\"color:black\">REST API <\/span><span style=\"color:black\">\u5c31\u662f\u4e00\u7c7b\u5f88\u91cd\u8981\u7684\u5165\u53e3&#xff0c;\u5b8c\u6210\u4ece<\/span><span style=\"color:black\"> HTTP <\/span><span style=\"color:black\">\u5230<\/span><span style=\"color:black\"> WordPress <\/span><span style=\"color:black\">\u5185\u90e8\u529f\u80fd\u7684\u5bf9\u63a5\u3002<\/span><\/p>\n<p style=\"margin-left:0;text-align:justify\"><span style=\"color:black\">\u56e0\u6b64\u6574\u4f53\u653b\u51fb\u6570\u636e\u6d41\u4e3a&#xff1a;<span style=\"background-color:#ffd900\">\u653b\u51fb\u8005\u53d1\u9001<\/span><\/span><span style=\"color:black\"><span style=\"background-color:#ffd900\"> HTTP <\/span><\/span><span style=\"color:black\"><span style=\"background-color:#ffd900\">\u8bf7\u6c42&#xff0c;\u8bf7\u6c42\u5230\u8fbe<\/span><\/span><span style=\"color:black\"><span style=\"background-color:#ffd900\"> REST API<\/span><\/span><span style=\"color:black\"><span style=\"background-color:#ffd900\">&#xff0c;\u63a5\u53e3\u5904\u7406<\/span><\/span><span style=\"color:black\"><span style=\"background-color:#ffd900\"> Posts <\/span><\/span><span style=\"color:black\"><span style=\"background-color:#ffd900\">\u8d44\u6e90\u67e5\u8be2&#xff0c;\u5185\u90e8\u8c03\u7528<\/span><\/span><span style=\"color:black\"><span style=\"background-color:#ffd900\"> WP_Query<\/span><\/span><span style=\"color:black\"><span style=\"background-color:#ffd900\">&#xff0c;\u6700\u540e\u7531<\/span><\/span><span style=\"color:black\"><span style=\"background-color:#ffd900\"> WP_Query <\/span><\/span><span style=\"color:black\"><span style=\"background-color:#ffd900\">\u62fc\u63a5\u751f\u6210<\/span><\/span><span style=\"color:black\"><span style=\"background-color:#ffd900\"> SQL <\/span><\/span><span style=\"color:black\"><span style=\"background-color:#ffd900\">\u8bed\u53e5\u6267\u884c\u6570\u636e\u5e93\u67e5\u8be2\u3002<\/span><\/span><\/p>\n<p style=\"margin-left:0;text-align:justify\">\n<h2><\/h2>\n<h2 style=\"background-color:transparent\">\u8c03\u7528WP_Query\u5728\u54ea\u91cc<\/h2>\n<p>\u201c\u54ea\u4e00\u5904\u4ee3\u7801\u4f1a\u8c03\u7528 WP_Query \u505a\u6587\u7ae0\u67e5\u8be2&#xff1f;<\/p>\n<p>\u5728wp-includes\/rest-api\/endpoints\/class-wp-rest-posts-controller.php\u4e2d\u7684<\/p>\n<p>WP_REST_Posts_Controller::get_items()<\/p>\n<h2 style=\"margin-left:0px;text-align:justify\">\u5206\u6790\u5982\u4e0b<\/h2>\n<h2>\u7b2c\u4e00\u5c42&#xff1a;\u8c01\u8d1f\u8d23 Posts REST API&#xff1f;<\/h2>\n<p>\u6587\u4ef6&#xff1a;wp-includes\/rest-api\/endpoints\/class-wp-rest-posts-controller.php<\/p>\n<p><img loading=\"lazy\" decoding=\"async\" alt=\"\" height=\"516\" src=\"https:\/\/www.wsisp.com\/helps\/wp-content\/uploads\/2026\/08\/20260829134923-6a92e3636a80f.png\" width=\"902\" \/><\/p>\n<p>\u8fd9\u91cc\u5df2\u7ecf\u544a\u8bc9\u6211\u4eec&#xff1a;Core class to access posts via the REST API\u3002\u4e5f\u5c31\u662f&#xff1a;\u7528 REST API \u8bbf\u95ee Posts \u7684\u6838\u5fc3\u7c7b\u3002<\/p>\n<p>WP_REST_Posts_Controller \u5c31\u662f Posts \u7684 REST API Controller\u3002<\/p>\n<h2>\u7b2c\u4e8c\u5c42&#xff1a;\u8fd9\u4e2a Controller \u600e\u4e48\u77e5\u9053\u81ea\u5df1\u8d1f\u8d23 \/posts&#xff1f;<\/h2>\n<p>\u770b\u8fd9\u4e2a\u6587\u4ef6\u4e2d\u7684\u6784\u9020\u51fd\u6570&#xff1a;public function __construct()&#xff1a;<\/p>\n<p>\u4f5c\u7528&#xff1a;\u5b9e\u4f8b\u5316\u8fd9\u4e2a\u7c7b\u7684\u65f6\u5019\u81ea\u52a8\u6267\u884c&#xff0c;\u63a5\u6536\u6587\u7ae0\u7c7b\u578b\u53c2\u6570\u505a\u521d\u59cb\u5316\u3002<\/p>\n<p><img loading=\"lazy\" decoding=\"async\" alt=\"\" height=\"301\" src=\"https:\/\/www.wsisp.com\/helps\/wp-content\/uploads\/2026\/08\/20260829134923-6a92e36396860.png\" width=\"1014\" \/><\/p>\n<h3>$this-&gt;namespace \u662f\u4ec0\u4e48&#xff1f;wp\/v2<\/h3>\n<p>$this-&gt;namespace &#061; ! empty( $obj-&gt;rest_namespace )? $obj-&gt;rest_namespace: &#039;wp\/v2&#039;;<\/p>\n<p>\u9ed8\u8ba4\u6ce8\u518c\u6587\u7ae0\u7c7b\u578b\u65f6\u6ca1\u6709\u8bbe\u7f6e rest_namespace&#xff0c;$obj-&gt;rest_namespace\u4e3a\u7a7a\u3002<\/p>\n<p style=\"margin-left:0;text-align:justify\">\u8fd9\u91cc\u6700\u7ec8\u4f1a\u5f97\u5230&#xff1a;$this-&gt;namespace\u7684\u503c\u4e3awp\/v2\u3002\u6240\u4ee5wp\/v2\u5c31\u662f\u8fd9\u4e2a REST API Controller \u6240\u4f7f\u7528\u7684 namespace\u3002<\/p>\n<hr \/>\n<h3 style=\"margin-left:0px;text-align:justify\">$this-&gt;rest_base \u662f\u4ec0\u4e48&#xff1f;posts<\/h3>\n<p>$this-&gt;rest_base &#061; ! empty( $obj-&gt;rest_base )? $obj-&gt;rest_base: $obj-&gt;name;<\/p>\n<p style=\"margin-left:0;text-align:justify\">\u5b83\u51b3\u5b9a&#xff1a;\u8fd9\u4e2a\u8d44\u6e90\u5728 REST API URL \u4e2d\u4f7f\u7528\u4ec0\u4e48\u540d\u5b57\u3002<\/p>\n<p style=\"margin-left:0;text-align:justify\">\n<p>$obj-&gt;name &#061; post&#xff08;\u6570\u636e\u7c7b\u578b\u5185\u90e8\u540d\u79f0&#xff0c;\u5355\u6570&#xff09;<\/p>\n<p>\u6ce8\u518c post \u7c7b\u578b\u65f6\u624b\u52a8\u8bbe\u7f6e\u4e86rest_base&#061;&#034;posts&#034; <\/p>\n<p>$obj-&gt;rest_base\u4e0d\u4e3a\u7a7a&#xff0c;\u6240\u4ee5 $this-&gt;rest_base &#061; &#034;posts&#034;<\/p>\n<p>\u6240\u4ee5\u63a5\u53e3\u8def\u5f84\u662f \/wp\u2011json\/wp\/v2\/posts&#xff0c;\u800c\u4e0d\u662f \/wp\u2011json\/wp\/v2\/post<\/p>\n<p style=\"margin-left:0;text-align:justify\">\u5bf9\u4e8e WordPress \u9ed8\u8ba4\u7684\u6587\u7ae0 Post Type&#xff1a;post&#xff0c;\u5bf9\u5e94\u7684 REST base \u662f&#xff1a;posts<\/p>\n<p style=\"margin-left:0;text-align:justify\">\u6240\u4ee5\u73b0\u5728\u6709&#xff1a;<\/p>\n<p style=\"margin-left:0;text-align:justify\">$this-&gt;namespace\u7684\u503c\u4e3awp\/v2<\/p>\n<p style=\"margin-left:0;text-align:justify\">$this-&gt;rest_base\u7684\u503c\u4e3aposts<\/p>\n<p style=\"margin-left:0;text-align:justify\">\u8fd9\u4e24\u4e2a\u4e1c\u897f\u7a0d\u540e\u4f1a\u88ab\u62fc\u8d77\u6765&#xff0c;<\/p>\n<hr \/>\n<h2>\u7b2c\u4e09\u5c42&#xff1a;\u771f\u6b63\u628a \/wp\/v2\/posts \u6ce8\u518c\u51fa\u6765\u7684\u4ee3\u7801\u5728\u54ea\u91cc&#xff1f;<\/h2>\n<p>\u6838\u5fc3\u4ee3\u7801\u662f&#xff1a;<img loading=\"lazy\" decoding=\"async\" alt=\"\" height=\"447\" src=\"https:\/\/www.wsisp.com\/helps\/wp-content\/uploads\/2026\/08\/20260829134923-6a92e363b9843.png\" width=\"1116\" \/><\/p>\n<table>\n<tr>\u5e38\u91cf\u5b9e\u9645 HTTP \u65b9\u6cd5\u5bf9\u5e94\u56fe\u4e2d\u56de\u8c03\u4f5c\u7528<\/tr>\n<tbody>\n<tr>\n<td>READABLE<\/td>\n<td>GET<\/td>\n<td>get_items()<\/td>\n<td><span style=\"background-color:#ffd900\">\u8bfb\u53d6\u8d44\u6e90&#xff0c;\u83b7\u53d6\u6587\u7ae0\u5217\u8868<\/span><span style=\"background-color:#ffd900\">&#xff0c;\u53ea\u8bfb\u64cd\u4f5c&#xff0c;\u4e0d\u4f1a\u4fee\u6539\u6570\u636e\u5e93<\/span><\/td>\n<\/tr>\n<tr>\n<td>CREATABLE<\/td>\n<td>POST<\/td>\n<td>create_item()<\/td>\n<td>\u65b0\u5efa\u8d44\u6e90&#xff0c;\u521b\u5efa\u4e00\u7bc7\u65b0\u6587\u7ae0&#xff0c;\u5199\u5165\u6570\u636e\u5e93&#xff0c;\u63d0\u4ea4\u6570\u636e<\/td>\n<\/tr>\n<\/tbody>\n<\/table>\n<p>\u5728\u8fd9\u91cc\u8c03\u7528\u4e86register_rest_route(&#xff09;\u51fd\u6570<\/p>\n<p><img loading=\"lazy\" decoding=\"async\" alt=\"\" height=\"172\" src=\"https:\/\/www.wsisp.com\/helps\/wp-content\/uploads\/2026\/08\/20260829134924-6a92e3640163f.png\" width=\"1112\" \/><\/p>\n<p style=\"margin-left:0;text-align:justify\">register_rest_route(&#xff09;\u8fd9\u4e2a\u51fd\u6570\u7684\u4f5c\u7528&#xff1a;\u5411 WordPress REST API \u6ce8\u518c\u4e00\u4e2a\u8def\u7531\u3002\u4e5f\u5c31\u662f\u8bf4&#xff1a;\u201c\u4ee5\u540e\u6709\u4eba\u8bbf\u95ee\u8fd9\u4e2a URL&#xff0c;\u5e94\u8be5\u4ea4\u7ed9\u54ea\u4e2a\u4ee3\u7801\u5904\u7406&#xff1f;\u201d\u5c31\u662f\u5728\u8fd9\u91cc\u5efa\u7acb\u5173\u7cfb\u3002<\/p>\n<p>trim \u2014 \u53bb\u9664\u5b57\u7b26\u4e32\u9996\u5c3e\u5904\u7684\u7a7a\u767d\u5b57\u7b26&#xff08;\u6216\u8005\u5176\u4ed6\u5b57\u7b26&#xff09;\u8fd9\u91cc\u662f\/<\/p>\n<h4>\u6ce8\u518c<span style=\"background-color:null\">\/wp\/v2\/posts<\/span><\/h4>\n<p><img loading=\"lazy\" decoding=\"async\" alt=\"\" height=\"196\" src=\"https:\/\/www.wsisp.com\/helps\/wp-content\/uploads\/2026\/08\/20260829134924-6a92e3642521c.png\" width=\"964\" \/><\/p>\n<p style=\"margin-left:0;text-align:justify\">\u8fd9\u513ffull_route\u6700\u7ec8\u62fc\u63a5\u6210<span style=\"background-color:#ffd900\">\/wp\/v2\/posts<\/span>&#xff0c;\u8c03\u7528register_route&#xff08;&#xff09;\u5b8c\u6210\u6ce8\u518c<\/p>\n<p>894\u2011914 \u884c&#xff1a;\u5224\u65ad\u547d\u540d\u7a7a\u95f4\u662f\u5426\u5b58\u5728&#xff0c;\u4e0d\u5b58\u5728\u5c31\u81ea\u52a8\u6ce8\u518c\u4e00\u6761\u547d\u540d\u7a7a\u95f4\u7d22\u5f15\u8def\u7531<\/p>\n<p><img loading=\"lazy\" decoding=\"async\" alt=\"\" height=\"492\" src=\"https:\/\/www.wsisp.com\/helps\/wp-content\/uploads\/2026\/08\/20260829134924-6a92e36442a82.png\" width=\"1147\" \/><\/p>\n<p style=\"margin-left:0;text-align:justify\">$this\u2011&gt;endpoints<\/p>\n<p style=\"margin-left:0;text-align:justify\">\u4f5c\u7528&#xff1a;\u5185\u5b58\u91cc\u7684 REST \u8def\u7531\u6ce8\u518c\u8868&#xff0c;\u4fdd\u5b58\u5168\u90e8 API \u63a5\u53e3\u7684\u914d\u7f6e\u4fe1\u606f<\/p>\n<p>$this-&gt;endpoints[&#039;\/wp\/v2\/posts&#039;] &#061; $route_args;<\/p>\n<p style=\"margin-left:0;text-align:justify\">$route_args&#xff1a;\u5355\u6761 REST \u63a5\u53e3\u5168\u90e8\u8fd0\u884c\u914d\u7f6e\u3002\u5305\u542b\u8bf7\u6c42\u65b9\u6cd5\u3001\u4e1a\u52a1\u56de\u8c03\u3001\u6743\u9650\u56de\u8c03\u3001\u8bf7\u6c42\u53c2\u6570\u6821\u9a8c\u89c4\u5219\u3001\u547d\u540d\u7a7a\u95f4\u3002\u6ce8\u518c\u65f6\u5b58\u5165 endpoints&#xff1b;\u8bf7\u6c42\u5230\u6765\u8bfb\u53d6\u5b83&#xff0c;\u5b8c\u6210\u9274\u6743\u3001\u53c2\u6570\u6821\u9a8c\u3001\u6267\u884c\u63a7\u5236\u5668\u51fd\u6570\u3002<\/p>\n<p style=\"margin-left:0;text-align:justify\"><span style=\"background-color:#ffd900\">\u6240\u4ee5&#xff1a;<\/span><span style=\"background-color:#ffd900\">\/wp\/v2\/posts \u8fd9\u4e2aREST API \u8def\u7531<\/span><span style=\"background-color:#ffd900\">\u5c31\u662f\u5728\u8fd9\u91cc\u6ce8\u518c\u51fa\u6765\u7684<\/span><\/p>\n<hr \/>\n<h3>\u8fd9\u91cc\u6700\u91cd\u8981\u7684\u662f callback<\/h3>\n<p>&#039;callback&#039; &#061;&gt; array( $this, &#039;get_items&#039; ),<\/p>\n<p>\u5b83\u7684\u610f\u601d\u4e0d\u662f\u201c\u8c03\u7528 get_items\u201d\u3002\u800c\u662f&#xff1a;\u544a\u8bc9 REST API&#xff1a;\u4ee5\u540e\u6709\u4eba\u8bf7\u6c42\u8fd9\u4e2a\u8def\u7531&#xff0c;\u5e76\u4e14\u7b26\u5408\u8fd9\u4e2a\u65b9\u6cd5\u65f6&#xff0c;\u5e94\u8be5\u4ea4\u7ed9\u8c01\u5904\u7406\u3002<\/p>\n<p>\u8fd9\u91cc\u6307\u5b9a&#xff1a;\u8bbf\u95ee\u63a5\u53e3 \/wp\/v2\/posts&#xff0c;\u7a0b\u5e8f\u5339\u914d\u5230\u5bf9\u5e94\u7684 REST \u8def\u7531&#xff0c;\u8bfb\u53d6\u8def\u7531\u914d\u7f6e\u4e2d\u7684 callback \u56de\u8c03\u8bbe\u7f6e\u3002callback \u6307\u5b9a\u4f7f\u7528 WP_REST_Posts_Controller \u5bf9\u8c61\u7684 get_items \u65b9\u6cd5&#xff0c;\u7a0b\u5e8f\u8c03\u7528\u8be5\u5bf9\u8c61\u7684 get_items () \u65b9\u6cd5&#xff0c;\u8be5\u65b9\u6cd5\u5b8c\u6210\u6570\u636e\u67e5\u8be2&#xff0c;\u8fd4\u56de\u6587\u7ae0\u5217\u8868\u7684 JSON \u6570\u636e\u3002<\/p>\n<p><span style=\"background-color:#ffd900\">\u6240\u4ee5GET \/wp-json\/wp\/v2\/posts&#xff0c;\u6700\u7ec8\u5bf9\u5e94&#xff1a;WP_REST_Posts_Controller::get_items()<\/span><\/p>\n<p>\u6240\u4ee5\u73b0\u5728\u6574\u4e2a\u5173\u7cfb\u5df2\u7ecf\u662f&#xff1a;<\/p>\n<li style=\"text-align:justify\">\u5ba2\u6237\u7aef\u53d1\u8d77 HTTP \u8bf7\u6c42&#xff1a;GET \/wp\u2011json\/wp\/v2\/posts<\/li>\n<li style=\"text-align:justify\">WordPress \u6846\u67b6\u5265\u79bb URL \u524d\u7f00\/wp\u2011json&#xff0c;\u5f97\u5230\u5185\u90e8\u8def\u7531\u8def\u5f84&#xff1a;\/wp\/v2\/posts<\/li>\n<li style=\"text-align:justify\">REST \u670d\u52a1\u5728$this\u2011&gt;endpoints\u8def\u7531\u8868\u5339\u914d\u5230\/wp\/v2\/posts&#xff0c;\u627e\u5230\u5bf9\u5e94\u63a7\u5236\u5668 WP_REST_Posts_Controller<\/li>\n<li style=\"text-align:justify\">\u6839\u636e HTTP \u65b9\u6cd5\u4e3a GET&#xff0c;\u8c03\u5ea6\u6267\u884c\u63a7\u5236\u5668\u65b9\u6cd5 get_items()<\/li>\n<li style=\"text-align:justify\"><span style=\"background-color:#a2e043\">get_items() \u67e5\u8be2\u6587\u7ae0\u6570\u636e&#xff0c;\u6700\u7ec8\u8fd4\u56de JSON \u54cd\u5e94\u3002<\/span><\/li>\n<hr \/>\n<h2 style=\"background-color:transparent\">get_itms()\u67e5\u8be2<\/h2>\n<p>public function get_items( $request )<\/p>\n<p>\u8fd9\u5c31\u662f\u521a\u624d callback \u6307\u5411\u7684\u51fd\u6570\u3002<\/p>\n<p><img loading=\"lazy\" decoding=\"async\" alt=\"\" height=\"237\" src=\"https:\/\/www.wsisp.com\/helps\/wp-content\/uploads\/2026\/08\/20260829134924-6a92e36482651.png\" width=\"949\" \/><\/p>\n<li style=\"text-align:justify\">prepare_items_query&#xff1a;\u5c06 REST \u63a5\u53e3\u8bf7\u6c42\u53c2\u6570&#xff0c;\u8f6c\u6362\u6210WP_Query\u53ef\u7528\u7684\u67e5\u8be2\u6761\u4ef6\u6570\u7ec4$query_args<\/li>\n<li style=\"text-align:justify\">new WP_Query()&#xff1a;\u5b9e\u4f8b\u5316 WordPress \u6587\u7ae0\u67e5\u8be2\u5bf9\u8c61<\/li>\n<li style=\"text-align:justify\">$posts_query-&gt;query($query_args)&#xff1a;\u4f20\u5165\u67e5\u8be2\u6761\u4ef6&#xff0c;\u6267\u884c\u6570\u636e\u5e93\u67e5\u8be2&#xff0c;\u83b7\u53d6\u6587\u7ae0\u6570\u636e<\/li>\n<p>$query_result &#061; $posts_query-&gt;query( $query_args );<\/p>\n<p>\u8fd9\u5c31\u662f&#xff1a;Posts REST API \u6700\u7ec8\u8c03\u7528 WP_Query \u67e5\u8be2\u6587\u7ae0\u7684\u771f\u5b9e\u4ee3\u7801<\/p>\n<hr \/>\n<p style=\"text-align:justify\">prepare_items_query&#xff08;&#xff09;&#xff1a;\u5c06 REST \u63a5\u53e3\u7684 HTTP \u8bf7\u6c42\u53c2\u6570&#xff0c;\u8f6c\u6362\u4e3a WP_Query \u53ef\u8bc6\u522b\u7684\u67e5\u8be2\u53c2\u6570\u6570\u7ec4&#xff0c;\u5b8c\u6210\u53c2\u6570\u6620\u5c04\u3001\u9002\u914d\u5904\u7406&#xff0c;\u8fd4\u56de\u7ec4\u88c5\u597d\u7684$query_args&#xff0c;\u4f9b\u540e\u7eed WP_Query \u6267\u884c\u6570\u636e\u5e93\u67e5\u8be2\u3002<\/p>\n<p style=\"text-align:justify\">\u4f8b\u5982&#xff1a;GET \/wp-json\/wp\/v2\/posts?author_exclude&#061;2,6<\/p>\n<p style=\"margin-left:0;text-align:justify\">WordPress \u5185\u90e8\u201c\u7ffb\u8bd1\u201d&#xff1a;\u8bf7\u6c42\u5230\u8fbe\u670d\u52a1\u5668\u540e&#xff0c;prepare_items_query() \u65b9\u6cd5\u4f1a\u8d1f\u8d23\u5c06 REST API \u7684\u53c2\u6570&#xff08;author_exclude&#xff09;\u201c\u7ffb\u8bd1\u201d\u6210 WP_Query \u80fd\u7406\u89e3\u7684\u53c2\u6570\u3002\u76f8\u5173\u7684\u6620\u5c04\u5173\u7cfb\u5728 WordPress \u6838\u5fc3\u4ee3\u7801\u4e2d\u6709\u660e\u786e\u5b9a\u4e49&#xff0c;\u7528\u4e8e\u8f6c\u6362\u53c2\u6570\u3002<\/p>\n<p style=\"margin-left:0;text-align:justify\"><span style=\"background-color:#ffd900\">author_exclude \u8fd9\u4e2a\u7528\u6237\u53cb\u597d\u7684\u53c2\u6570\u4f1a\u88ab\u6620\u5c04\u4e3a author__not_in\u3002<\/span>\u7ffb\u8bd1\u540e&#xff0c;WP_Query \u63a5\u6536\u5230\u7684\u67e5\u8be2\u53c2\u6570\u5c31\u662f &#039;author__not_in&#039; &#061;&gt; [2, 6]\u3002<\/p>\n<p style=\"margin-left:0;text-align:justify\">\u6267\u884c\u67e5\u8be2&#xff1a;WP_Query \u62ff\u5230 author__not_in \u53c2\u6570\u540e&#xff0c;\u4f1a\u6784\u5efa SQL \u67e5\u8be2\u8bed\u53e5&#xff0c;\u4ece\u6570\u636e\u5e93\u4e2d\u6392\u9664\u4f5c\u8005 ID \u4e3a 2 \u548c 6 \u7684\u6240\u6709\u6587\u7ae0&#xff0c;\u6700\u7ec8\u8fd4\u56de\u7b26\u5408\u6761\u4ef6\u7684\u7ed3\u679c\u3002<\/p>\n<p>$query_args &#061; array(<br \/>\n    &#039;posts_per_page&#039;    &#061;&gt; 10,          \/\/ \u9ed8\u8ba4\u503c<br \/>\n    &#039;paged&#039;             &#061;&gt; 1,           \/\/ \u9ed8\u8ba4\u503c<br \/>\n    &#039;post_status&#039;       &#061;&gt; &#039;publish&#039;,   \/\/ \u9ed8\u8ba4\u503c<br \/>\n    &#039;post_type&#039;         &#061;&gt; &#039;post&#039;,      \/\/ \u9ed8\u8ba4\u503c<br \/>\n    &#039;orderby&#039;           &#061;&gt; &#039;date&#039;,      \/\/ \u9ed8\u8ba4\u503c<br \/>\n    &#039;order&#039;             &#061;&gt; &#039;DESC&#039;,      \/\/ \u9ed8\u8ba4\u503c<br \/>\n    &#039;author__not_in&#039;    &#061;&gt; array(2, 6), \/\/  author_exclude \u6620\u5c04\u8fc7\u6765\u7684<br \/>\n    &#039;ignore_sticky_posts&#039; &#061;&gt; true,      \/\/ \u9ed8\u8ba4\u503c<br \/>\n    &#039;suppress_filters&#039;  &#061;&gt; true,        \/\/ \u9ed8\u8ba4\u503c<br \/>\n);<\/p>\n<p><img loading=\"lazy\" decoding=\"async\" alt=\"\" height=\"835\" src=\"https:\/\/www.wsisp.com\/helps\/wp-content\/uploads\/2026\/08\/20260829134924-6a92e364a2671.png\" width=\"1205\" \/><\/p>\n<p>\u771f\u6b63\u6267\u884cWP_Query \u67e5\u8be2\u6587\u7ae0\u7684\u5730\u65b9<\/p>\n<p><img loading=\"lazy\" decoding=\"async\" alt=\"\" height=\"287\" src=\"https:\/\/www.wsisp.com\/helps\/wp-content\/uploads\/2026\/08\/20260829134925-6a92e3650dfe5.png\" width=\"761\" \/><\/p>\n<li style=\"text-align:justify\">\u4fdd\u5b58\u53c2\u6570&#xff1a;\u628a\u4f20\u5165\u7684 $query \u4fdd\u5b58\u5230\u5bf9\u8c61\u7684 query \u548c query_vars \u5c5e\u6027\u4e2d\u3002<\/li>\n<li style=\"text-align:justify\">\u6267\u884c\u67e5\u8be2&#xff1a;\u8c03\u7528 return $this-&gt;get_posts()&#xff0c;\u8fd9\u4e2a\u65b9\u6cd5\u5185\u90e8\u4f1a\u6784\u5efa SQL \u8bed\u53e5&#xff0c;\u8fde\u63a5\u6570\u636e\u5e93&#xff0c;\u628a\u6587\u7ae0\u6570\u636e\u67e5\u51fa\u6765\u5e76\u8fd4\u56de\u3002<\/li>\n<p style=\"margin-left:0;text-align:justify\">\u8fd9\u91cc\u4e5f\u5c31\u56de\u5230\u4e86\u6587\u7ae0\u5f00\u5934\u7684\u67e5\u8be2\u90e8\u5206\u3002<\/p>\n","protected":false},"excerpt":{"rendered":"<p>\u6458\u8981&#xff1a;\u672c\u6587\u57fa\u4e8e WordPress 7.0.1 \u6e90\u7801&#xff0c;\u5b8c\u6574\u68b3\u7406\u4e86\u4e00\u6761 SQL \u6ce8\u5165\u6f0f\u6d1e\u7684\u5f62\u6210\u4e0e\u5229\u7528\u94fe\u8def&#xff1a;author__not_in \u53c2\u6570\u5728 WP_Query \u4e2d\u88ab\u62fc\u5165 post_author NOT IN (&#8230;)&#xff0c;\u800c\u5f00\u53d1\u8005\u4ec5\u7528 is_array() \u505a\u4e86\u5b89\u5168\u68c0\u67e5&#xff0c;\u5bfc\u81f4\u5b57\u7b26\u4e32\u7c7b\u578b\u7684\u8f93\u5165\u53ef\u4ee5\u7ed5\u8fc7 absint() \u5f3a\u5236\u6574\u6570\u8f6c\u6362&#xff0c;\u539f\u59cb\u6076\u610f\u5b57\u7b26\u4e32\u76f4\u63a5\u8fdb\u5165 SQL\u3002\u4e3a\u8bf4\u660e\u653b\u51fb\u8005\u5982\u4f55\u8ba9\u5185\u90e8\u53c2\u6570\u63a5\u6536\u5916<\/p>\n","protected":false},"author":2,"featured_media":97599,"comment_status":"open","ping_status":"open","sticky":false,"template":"","format":"standard","meta":{"footnotes":""},"categories":[1],"tags":[58,87,100],"topic":[],"class_list":["post-97617","post","type-post","status-publish","format-standard","has-post-thumbnail","hentry","category-server","tag-linux","tag-87","tag-100"],"yoast_head":"<!-- This site is optimized with the Yoast SEO plugin v20.3 - https:\/\/yoast.com\/wordpress\/plugins\/seo\/ -->\n<title>WordPress SQL \u6ce8\u5165\u6f0f\u6d1e\u5206\u6790\uff1a\u4ece author__not_in \u53c2\u6570\u5230 REST API \u5168\u94fe\u8def - \u7f51\u7855\u4e92\u8054\u5e2e\u52a9\u4e2d\u5fc3<\/title>\n<meta name=\"robots\" content=\"index, follow, max-snippet:-1, max-image-preview:large, max-video-preview:-1\" \/>\n<link rel=\"canonical\" href=\"https:\/\/www.wsisp.com\/helps\/97617.html\" \/>\n<meta property=\"og:locale\" content=\"zh_CN\" \/>\n<meta property=\"og:type\" content=\"article\" \/>\n<meta property=\"og:title\" content=\"WordPress SQL \u6ce8\u5165\u6f0f\u6d1e\u5206\u6790\uff1a\u4ece author__not_in \u53c2\u6570\u5230 REST API \u5168\u94fe\u8def - \u7f51\u7855\u4e92\u8054\u5e2e\u52a9\u4e2d\u5fc3\" \/>\n<meta property=\"og:description\" content=\"\u6458\u8981&#xff1a;\u672c\u6587\u57fa\u4e8e WordPress 7.0.1 \u6e90\u7801&#xff0c;\u5b8c\u6574\u68b3\u7406\u4e86\u4e00\u6761 SQL \u6ce8\u5165\u6f0f\u6d1e\u7684\u5f62\u6210\u4e0e\u5229\u7528\u94fe\u8def&#xff1a;author__not_in \u53c2\u6570\u5728 WP_Query \u4e2d\u88ab\u62fc\u5165 post_author NOT IN (...)&#xff0c;\u800c\u5f00\u53d1\u8005\u4ec5\u7528 is_array() \u505a\u4e86\u5b89\u5168\u68c0\u67e5&#xff0c;\u5bfc\u81f4\u5b57\u7b26\u4e32\u7c7b\u578b\u7684\u8f93\u5165\u53ef\u4ee5\u7ed5\u8fc7 absint() \u5f3a\u5236\u6574\u6570\u8f6c\u6362&#xff0c;\u539f\u59cb\u6076\u610f\u5b57\u7b26\u4e32\u76f4\u63a5\u8fdb\u5165 SQL\u3002\u4e3a\u8bf4\u660e\u653b\u51fb\u8005\u5982\u4f55\u8ba9\u5185\u90e8\u53c2\u6570\u63a5\u6536\u5916\" \/>\n<meta property=\"og:url\" content=\"https:\/\/www.wsisp.com\/helps\/97617.html\" \/>\n<meta property=\"og:site_name\" content=\"\u7f51\u7855\u4e92\u8054\u5e2e\u52a9\u4e2d\u5fc3\" \/>\n<meta property=\"article:published_time\" content=\"2026-08-29T13:49:26+00:00\" \/>\n<meta property=\"og:image\" content=\"https:\/\/www.wsisp.com\/helps\/wp-content\/uploads\/2026\/08\/20260829134922-6a92e3620c6ab.png\" \/>\n<meta name=\"author\" content=\"admin\" \/>\n<meta name=\"twitter:card\" content=\"summary_large_image\" \/>\n<meta name=\"twitter:label1\" content=\"\u4f5c\u8005\" \/>\n\t<meta name=\"twitter:data1\" content=\"admin\" \/>\n\t<meta name=\"twitter:label2\" content=\"\u9884\u8ba1\u9605\u8bfb\u65f6\u95f4\" \/>\n\t<meta name=\"twitter:data2\" content=\"7 \u5206\" \/>\n<script type=\"application\/ld+json\" class=\"yoast-schema-graph\">{\"@context\":\"https:\/\/schema.org\",\"@graph\":[{\"@type\":\"WebPage\",\"@id\":\"https:\/\/www.wsisp.com\/helps\/97617.html\",\"url\":\"https:\/\/www.wsisp.com\/helps\/97617.html\",\"name\":\"WordPress SQL \u6ce8\u5165\u6f0f\u6d1e\u5206\u6790\uff1a\u4ece author__not_in \u53c2\u6570\u5230 REST API \u5168\u94fe\u8def - \u7f51\u7855\u4e92\u8054\u5e2e\u52a9\u4e2d\u5fc3\",\"isPartOf\":{\"@id\":\"https:\/\/www.wsisp.com\/helps\/#website\"},\"datePublished\":\"2026-08-29T13:49:26+00:00\",\"dateModified\":\"2026-08-29T13:49:26+00:00\",\"author\":{\"@id\":\"https:\/\/www.wsisp.com\/helps\/#\/schema\/person\/358e386c577a3ab51c4493330a20ad41\"},\"breadcrumb\":{\"@id\":\"https:\/\/www.wsisp.com\/helps\/97617.html#breadcrumb\"},\"inLanguage\":\"zh-Hans\",\"potentialAction\":[{\"@type\":\"ReadAction\",\"target\":[\"https:\/\/www.wsisp.com\/helps\/97617.html\"]}]},{\"@type\":\"BreadcrumbList\",\"@id\":\"https:\/\/www.wsisp.com\/helps\/97617.html#breadcrumb\",\"itemListElement\":[{\"@type\":\"ListItem\",\"position\":1,\"name\":\"\u9996\u9875\",\"item\":\"https:\/\/www.wsisp.com\/helps\"},{\"@type\":\"ListItem\",\"position\":2,\"name\":\"WordPress SQL \u6ce8\u5165\u6f0f\u6d1e\u5206\u6790\uff1a\u4ece author__not_in \u53c2\u6570\u5230 REST API \u5168\u94fe\u8def\"}]},{\"@type\":\"WebSite\",\"@id\":\"https:\/\/www.wsisp.com\/helps\/#website\",\"url\":\"https:\/\/www.wsisp.com\/helps\/\",\"name\":\"\u7f51\u7855\u4e92\u8054\u5e2e\u52a9\u4e2d\u5fc3\",\"description\":\"\u9999\u6e2f\u670d\u52a1\u5668_\u9999\u6e2f\u4e91\u670d\u52a1\u5668\u8d44\u8baf_\u670d\u52a1\u5668\u5e2e\u52a9\u6587\u6863_\u670d\u52a1\u5668\u6559\u7a0b\",\"potentialAction\":[{\"@type\":\"SearchAction\",\"target\":{\"@type\":\"EntryPoint\",\"urlTemplate\":\"https:\/\/www.wsisp.com\/helps\/?s={search_term_string}\"},\"query-input\":\"required name=search_term_string\"}],\"inLanguage\":\"zh-Hans\"},{\"@type\":\"Person\",\"@id\":\"https:\/\/www.wsisp.com\/helps\/#\/schema\/person\/358e386c577a3ab51c4493330a20ad41\",\"name\":\"admin\",\"image\":{\"@type\":\"ImageObject\",\"inLanguage\":\"zh-Hans\",\"@id\":\"https:\/\/www.wsisp.com\/helps\/#\/schema\/person\/image\/\",\"url\":\"https:\/\/gravatar.wp-china-yes.net\/avatar\/?s=96&d=mystery\",\"contentUrl\":\"https:\/\/gravatar.wp-china-yes.net\/avatar\/?s=96&d=mystery\",\"caption\":\"admin\"},\"sameAs\":[\"http:\/\/wp.wsisp.com\"],\"url\":\"https:\/\/www.wsisp.com\/helps\/author\/admin\"}]}<\/script>\n<!-- \/ Yoast SEO plugin. -->","yoast_head_json":{"title":"WordPress SQL \u6ce8\u5165\u6f0f\u6d1e\u5206\u6790\uff1a\u4ece author__not_in \u53c2\u6570\u5230 REST API \u5168\u94fe\u8def - \u7f51\u7855\u4e92\u8054\u5e2e\u52a9\u4e2d\u5fc3","robots":{"index":"index","follow":"follow","max-snippet":"max-snippet:-1","max-image-preview":"max-image-preview:large","max-video-preview":"max-video-preview:-1"},"canonical":"https:\/\/www.wsisp.com\/helps\/97617.html","og_locale":"zh_CN","og_type":"article","og_title":"WordPress SQL \u6ce8\u5165\u6f0f\u6d1e\u5206\u6790\uff1a\u4ece author__not_in \u53c2\u6570\u5230 REST API \u5168\u94fe\u8def - \u7f51\u7855\u4e92\u8054\u5e2e\u52a9\u4e2d\u5fc3","og_description":"\u6458\u8981&#xff1a;\u672c\u6587\u57fa\u4e8e WordPress 7.0.1 \u6e90\u7801&#xff0c;\u5b8c\u6574\u68b3\u7406\u4e86\u4e00\u6761 SQL \u6ce8\u5165\u6f0f\u6d1e\u7684\u5f62\u6210\u4e0e\u5229\u7528\u94fe\u8def&#xff1a;author__not_in \u53c2\u6570\u5728 WP_Query \u4e2d\u88ab\u62fc\u5165 post_author NOT IN (...)&#xff0c;\u800c\u5f00\u53d1\u8005\u4ec5\u7528 is_array() \u505a\u4e86\u5b89\u5168\u68c0\u67e5&#xff0c;\u5bfc\u81f4\u5b57\u7b26\u4e32\u7c7b\u578b\u7684\u8f93\u5165\u53ef\u4ee5\u7ed5\u8fc7 absint() \u5f3a\u5236\u6574\u6570\u8f6c\u6362&#xff0c;\u539f\u59cb\u6076\u610f\u5b57\u7b26\u4e32\u76f4\u63a5\u8fdb\u5165 SQL\u3002\u4e3a\u8bf4\u660e\u653b\u51fb\u8005\u5982\u4f55\u8ba9\u5185\u90e8\u53c2\u6570\u63a5\u6536\u5916","og_url":"https:\/\/www.wsisp.com\/helps\/97617.html","og_site_name":"\u7f51\u7855\u4e92\u8054\u5e2e\u52a9\u4e2d\u5fc3","article_published_time":"2026-08-29T13:49:26+00:00","og_image":[{"url":"https:\/\/www.wsisp.com\/helps\/wp-content\/uploads\/2026\/08\/20260829134922-6a92e3620c6ab.png"}],"author":"admin","twitter_card":"summary_large_image","twitter_misc":{"\u4f5c\u8005":"admin","\u9884\u8ba1\u9605\u8bfb\u65f6\u95f4":"7 \u5206"},"schema":{"@context":"https:\/\/schema.org","@graph":[{"@type":"WebPage","@id":"https:\/\/www.wsisp.com\/helps\/97617.html","url":"https:\/\/www.wsisp.com\/helps\/97617.html","name":"WordPress SQL \u6ce8\u5165\u6f0f\u6d1e\u5206\u6790\uff1a\u4ece author__not_in \u53c2\u6570\u5230 REST API \u5168\u94fe\u8def - \u7f51\u7855\u4e92\u8054\u5e2e\u52a9\u4e2d\u5fc3","isPartOf":{"@id":"https:\/\/www.wsisp.com\/helps\/#website"},"datePublished":"2026-08-29T13:49:26+00:00","dateModified":"2026-08-29T13:49:26+00:00","author":{"@id":"https:\/\/www.wsisp.com\/helps\/#\/schema\/person\/358e386c577a3ab51c4493330a20ad41"},"breadcrumb":{"@id":"https:\/\/www.wsisp.com\/helps\/97617.html#breadcrumb"},"inLanguage":"zh-Hans","potentialAction":[{"@type":"ReadAction","target":["https:\/\/www.wsisp.com\/helps\/97617.html"]}]},{"@type":"BreadcrumbList","@id":"https:\/\/www.wsisp.com\/helps\/97617.html#breadcrumb","itemListElement":[{"@type":"ListItem","position":1,"name":"\u9996\u9875","item":"https:\/\/www.wsisp.com\/helps"},{"@type":"ListItem","position":2,"name":"WordPress SQL \u6ce8\u5165\u6f0f\u6d1e\u5206\u6790\uff1a\u4ece author__not_in \u53c2\u6570\u5230 REST API \u5168\u94fe\u8def"}]},{"@type":"WebSite","@id":"https:\/\/www.wsisp.com\/helps\/#website","url":"https:\/\/www.wsisp.com\/helps\/","name":"\u7f51\u7855\u4e92\u8054\u5e2e\u52a9\u4e2d\u5fc3","description":"\u9999\u6e2f\u670d\u52a1\u5668_\u9999\u6e2f\u4e91\u670d\u52a1\u5668\u8d44\u8baf_\u670d\u52a1\u5668\u5e2e\u52a9\u6587\u6863_\u670d\u52a1\u5668\u6559\u7a0b","potentialAction":[{"@type":"SearchAction","target":{"@type":"EntryPoint","urlTemplate":"https:\/\/www.wsisp.com\/helps\/?s={search_term_string}"},"query-input":"required name=search_term_string"}],"inLanguage":"zh-Hans"},{"@type":"Person","@id":"https:\/\/www.wsisp.com\/helps\/#\/schema\/person\/358e386c577a3ab51c4493330a20ad41","name":"admin","image":{"@type":"ImageObject","inLanguage":"zh-Hans","@id":"https:\/\/www.wsisp.com\/helps\/#\/schema\/person\/image\/","url":"https:\/\/gravatar.wp-china-yes.net\/avatar\/?s=96&d=mystery","contentUrl":"https:\/\/gravatar.wp-china-yes.net\/avatar\/?s=96&d=mystery","caption":"admin"},"sameAs":["http:\/\/wp.wsisp.com"],"url":"https:\/\/www.wsisp.com\/helps\/author\/admin"}]}},"_links":{"self":[{"href":"https:\/\/www.wsisp.com\/helps\/wp-json\/wp\/v2\/posts\/97617","targetHints":{"allow":["GET"]}}],"collection":[{"href":"https:\/\/www.wsisp.com\/helps\/wp-json\/wp\/v2\/posts"}],"about":[{"href":"https:\/\/www.wsisp.com\/helps\/wp-json\/wp\/v2\/types\/post"}],"author":[{"embeddable":true,"href":"https:\/\/www.wsisp.com\/helps\/wp-json\/wp\/v2\/users\/2"}],"replies":[{"embeddable":true,"href":"https:\/\/www.wsisp.com\/helps\/wp-json\/wp\/v2\/comments?post=97617"}],"version-history":[{"count":0,"href":"https:\/\/www.wsisp.com\/helps\/wp-json\/wp\/v2\/posts\/97617\/revisions"}],"wp:featuredmedia":[{"embeddable":true,"href":"https:\/\/www.wsisp.com\/helps\/wp-json\/wp\/v2\/media\/97599"}],"wp:attachment":[{"href":"https:\/\/www.wsisp.com\/helps\/wp-json\/wp\/v2\/media?parent=97617"}],"wp:term":[{"taxonomy":"category","embeddable":true,"href":"https:\/\/www.wsisp.com\/helps\/wp-json\/wp\/v2\/categories?post=97617"},{"taxonomy":"post_tag","embeddable":true,"href":"https:\/\/www.wsisp.com\/helps\/wp-json\/wp\/v2\/tags?post=97617"},{"taxonomy":"topic","embeddable":true,"href":"https:\/\/www.wsisp.com\/helps\/wp-json\/wp\/v2\/topic?post=97617"}],"curies":[{"name":"wp","href":"https:\/\/api.w.org\/{rel}","templated":true}]}}