{"id":210182,"date":"2023-12-21T23:38:30","date_gmt":"2023-12-21T15:38:30","guid":{"rendered":"https:\/\/www.idc.net\/help\/210182\/"},"modified":"2023-12-21T23:38:30","modified_gmt":"2023-12-21T15:38:30","slug":"wordpress%e6%8f%92%e4%bb%b6-post-type-switcher","status":"publish","type":"post","link":"https:\/\/idc.net\/help\/210182\/","title":{"rendered":"WordPress\u63d2\u4ef6: Post Type Switcher"},"content":{"rendered":"<h1 id=\"wordpress%e6%8f%92%e4%bb%b6-post-type-switcher-bTLdgYcClm\">WordPress\u63d2\u4ef6: Post Type Switcher<\/h1>\n<p>WordPress\u662f\u4e00\u4e2a\u529f\u80fd\u5f3a\u5927\u7684\u5185\u5bb9\u7ba1\u7406\u7cfb\u7edf\uff0c\u5b83\u5141\u8bb8\u7528\u6237\u521b\u5efa\u548c\u7ba1\u7406\u5404\u79cd\u7c7b\u578b\u7684\u5185\u5bb9\u3002\u9ed8\u8ba4\u60c5\u51b5\u4e0b\uff0cWordPress\u63d0\u4f9b\u4e86\u4e00\u4e9b\u5e38\u89c1\u7684\u5185\u5bb9\u7c7b\u578b\uff0c\u5982\u6587\u7ae0\uff08post\uff09\u548c\u9875\u9762\uff08page\uff09\u3002\u7136\u800c\uff0c\u6709\u65f6\u5019\u6211\u4eec\u53ef\u80fd\u9700\u8981\u521b\u5efa\u81ea\u5b9a\u4e49\u7684\u5185\u5bb9\u7c7b\u578b\u6765\u6ee1\u8db3\u7279\u5b9a\u7684\u9700\u6c42\u3002\u8fd9\u5c31\u662fWordPress\u63d2\u4ef6\u201cPost Type Switcher\u201d\u53d1\u6325\u4f5c\u7528\u7684\u5730\u65b9\u3002<\/p>\n<h2 id=\"%e4%bb%80%e4%b9%88%e6%98%afpost-type-switcher%e6%8f%92%e4%bb%b6%ef%bc%9f-bTLdgYcClm\">\u4ec0\u4e48\u662fPost Type Switcher\u63d2\u4ef6\uff1f<\/h2>\n<p>Post Type Switcher\u662f\u4e00\u4e2a\u514d\u8d39\u7684WordPress\u63d2\u4ef6\uff0c\u5b83\u5141\u8bb8\u7528\u6237\u5728\u4e0d\u540c\u7684\u5185\u5bb9\u7c7b\u578b\u4e4b\u95f4\u8fdb\u884c\u5207\u6362\u3002\u901a\u8fc7\u8fd9\u4e2a\u63d2\u4ef6\uff0c\u7528\u6237\u53ef\u4ee5\u5c06\u5df2\u6709\u7684\u6587\u7ae0\u6216\u9875\u9762\u8f6c\u6362\u4e3a\u5176\u4ed6\u81ea\u5b9a\u4e49\u7684\u5185\u5bb9\u7c7b\u578b\uff0c\u6216\u8005\u5c06\u81ea\u5b9a\u4e49\u5185\u5bb9\u7c7b\u578b\u8f6c\u6362\u4e3a\u6587\u7ae0\u6216\u9875\u9762\u3002\u8fd9\u4e3a\u7528\u6237\u63d0\u4f9b\u4e86\u66f4\u5927\u7684\u7075\u6d3b\u6027\u548c\u81ea\u5b9a\u4e49\u6027\u3002<\/p>\n<h2 id=\"%e4%b8%ba%e4%bb%80%e4%b9%88%e4%bd%bf%e7%94%a8post-type-switcher%e6%8f%92%e4%bb%b6%ef%bc%9f-bTLdgYcClm\">\u4e3a\u4ec0\u4e48\u4f7f\u7528Post Type Switcher\u63d2\u4ef6\uff1f<\/h2>\n<p>Post Type Switcher\u63d2\u4ef6\u63d0\u4f9b\u4e86\u4e00\u79cd\u7b80\u5355\u800c\u6709\u6548\u7684\u65b9\u5f0f\u6765\u7ba1\u7406\u548c\u8f6c\u6362\u4e0d\u540c\u7684\u5185\u5bb9\u7c7b\u578b\u3002\u4ee5\u4e0b\u662f\u4e00\u4e9b\u4f7f\u7528\u8be5\u63d2\u4ef6\u7684\u597d\u5904\uff1a<\/p>\n<ol>\n<li><strong>\u7075\u6d3b\u6027\uff1a<\/strong>\u901a\u8fc7\u8be5\u63d2\u4ef6\uff0c\u7528\u6237\u53ef\u4ee5\u6839\u636e\u81ea\u5df1\u7684\u9700\u6c42\u968f\u65f6\u5207\u6362\u4e0d\u540c\u7684\u5185\u5bb9\u7c7b\u578b\uff0c\u800c\u65e0\u9700\u624b\u52a8\u590d\u5236\u548c\u7c98\u8d34\u5185\u5bb9\u3002<\/li>\n<li><strong>\u8282\u7701\u65f6\u95f4\uff1a<\/strong>\u4f7f\u7528Post Type Switcher\u63d2\u4ef6\u53ef\u4ee5\u8282\u7701\u5927\u91cf\u7684\u65f6\u95f4\u548c\u7cbe\u529b\uff0c\u7279\u522b\u662f\u5728\u9700\u8981\u9891\u7e41\u8f6c\u6362\u5185\u5bb9\u7c7b\u578b\u7684\u60c5\u51b5\u4e0b\u3002<\/li>\n<li><strong>\u81ea\u5b9a\u4e49\u6027\uff1a<\/strong>\u8be5\u63d2\u4ef6\u5141\u8bb8\u7528\u6237\u521b\u5efa\u81ea\u5b9a\u4e49\u7684\u5185\u5bb9\u7c7b\u578b\uff0c\u5e76\u5c06\u73b0\u6709\u7684\u5185\u5bb9\u8f6c\u6362\u4e3a\u8fd9\u4e9b\u81ea\u5b9a\u4e49\u7c7b\u578b\u3002\u8fd9\u4e3a\u7528\u6237\u63d0\u4f9b\u4e86\u66f4\u5927\u7684\u81ea\u5b9a\u4e49\u6027\u548c\u7075\u6d3b\u6027\u3002<\/li>\n<\/ol>\n<h2 id=\"%e5%a6%82%e4%bd%95%e4%bd%bf%e7%94%a8post-type-switcher%e6%8f%92%e4%bb%b6%ef%bc%9f-bTLdgYcClm\">\u5982\u4f55\u4f7f\u7528Post Type Switcher\u63d2\u4ef6\uff1f<\/h2>\n<p>\u4f7f\u7528Post Type Switcher\u63d2\u4ef6\u975e\u5e38\u7b80\u5355\u3002\u4ee5\u4e0b\u662f\u4f7f\u7528\u8be5\u63d2\u4ef6\u7684\u6b65\u9aa4\uff1a<\/p>\n<ol>\n<li>\u5728WordPress\u540e\u53f0\uff0c\u70b9\u51fb\u201c\u63d2\u4ef6\u201d\u83dc\u5355\uff0c\u7136\u540e\u70b9\u51fb\u201c\u5b89\u88c5\u63d2\u4ef6\u201d\u3002<\/li>\n<li>\u5728\u641c\u7d22\u6846\u4e2d\u8f93\u5165\u201cPost Type Switcher\u201d\uff0c\u7136\u540e\u70b9\u51fb\u201c\u641c\u7d22\u63d2\u4ef6\u201d\u3002<\/li>\n<li>\u627e\u5230Post Type Switcher\u63d2\u4ef6\uff0c\u5e76\u70b9\u51fb\u201c\u5b89\u88c5\u201d\u6309\u94ae\u3002<\/li>\n<li>\u5b89\u88c5\u5b8c\u6210\u540e\uff0c\u70b9\u51fb\u201c\u6fc0\u6d3b\u201d\u6309\u94ae\u3002<\/li>\n<li>\u73b0\u5728\uff0c\u5728\u6587\u7ae0\u6216\u9875\u9762\u7f16\u8f91\u9875\u9762\uff0c\u60a8\u5c06\u770b\u5230\u4e00\u4e2a\u4e0b\u62c9\u83dc\u5355\uff0c\u5141\u8bb8\u60a8\u9009\u62e9\u4e0d\u540c\u7684\u5185\u5bb9\u7c7b\u578b\u3002<\/li>\n<li>\u9009\u62e9\u60a8\u60f3\u8981\u8f6c\u6362\u7684\u5185\u5bb9\u7c7b\u578b\uff0c\u7136\u540e\u70b9\u51fb\u201c\u66f4\u65b0\u201d\u6309\u94ae\u3002<\/li>\n<\/ol>\n<h2 id=\"%e7%a4%ba%e4%be%8b%e4%bb%a3%e7%a0%81-bTLdgYcClm\">\u793a\u4f8b\u4ee3\u7801<\/h2>\n<p>\u4ee5\u4e0b\u662f\u4e00\u4e2a\u793a\u4f8b\u4ee3\u7801\uff0c\u6f14\u793a\u5982\u4f55\u4f7f\u7528Post Type Switcher\u63d2\u4ef6\u5c06\u6587\u7ae0\u8f6c\u6362\u4e3a\u81ea\u5b9a\u4e49\u5185\u5bb9\u7c7b\u578b\uff1a<\/p>\n<pre><code>\n\/\/ \u83b7\u53d6\u6587\u7ae0ID\n$post_id = get_the_ID();\n\n\/\/ \u5c06\u6587\u7ae0\u8f6c\u6362\u4e3a\u81ea\u5b9a\u4e49\u5185\u5bb9\u7c7b\u578b\n$post_type = 'custom_post_type';\nwp_update_post(array(\n  'ID' =&gt; $post_id,\n  'post_type' =&gt; $post_type\n));\n<\/code><\/pre>\n<p>\u5728\u4e0a\u9762\u7684\u793a\u4f8b\u4e2d\uff0c\u6211\u4eec\u9996\u5148\u83b7\u53d6\u5f53\u524d\u6587\u7ae0\u7684ID\uff0c\u7136\u540e\u4f7f\u7528wp_update_post\u51fd\u6570\u5c06\u6587\u7ae0\u7684\u5185\u5bb9\u7c7b\u578b\u66f4\u6539\u4e3a\u81ea\u5b9a\u4e49\u5185\u5bb9\u7c7b\u578b\u3002<\/p>\n<h2 id=\"%e6%80%bb%e7%bb%93-bTLdgYcClm\">\u603b\u7ed3<\/h2>\n<p>Post Type Switcher\u63d2\u4ef6\u662f\u4e00\u4e2a\u975e\u5e38\u6709\u7528\u7684WordPress\u63d2\u4ef6\uff0c\u5b83\u5141\u8bb8\u7528\u6237\u5728\u4e0d\u540c\u7684\u5185\u5bb9\u7c7b\u578b\u4e4b\u95f4\u8fdb\u884c\u5207\u6362\u3002\u901a\u8fc7\u8be5\u63d2\u4ef6\uff0c\u7528\u6237\u53ef\u4ee5\u66f4\u7075\u6d3b\u5730\u7ba1\u7406\u548c\u8f6c\u6362\u4e0d\u540c\u7c7b\u578b\u7684\u5185\u5bb9\u3002\u5982\u679c\u60a8\u9700\u8981\u5728WordPress\u4e2d\u8fdb\u884c\u5185\u5bb9\u7c7b\u578b\u8f6c\u6362\uff0c\u6211\u5f3a\u70c8\u63a8\u8350\u60a8\u4f7f\u7528Post Type Switcher\u63d2\u4ef6\u3002<\/p>\n<h3 id=\"%e9%a6%99%e6%b8%af%e6%9c%8d%e5%8a%a1%e5%99%a8%e9%a6%96%e9%80%89%e5%90%8e%e6%b5%aa%e4%ba%91-bTLdgYcClm\">\u9999\u6e2f\u670d\u52a1\u5668\u9996\u9009\u540e\u6d6a\u4e91<\/h3>\n<p>\u5982\u679c\u60a8\u6b63\u5728\u5bfb\u627e\u53ef\u9760\u7684\u9999\u6e2f\u670d\u52a1\u5668\u63d0\u4f9b\u5546\uff0c\u8bf7\u8003\u8651\u9009\u62e9\u540e\u6d6a\u4e91\u3002\u540e\u6d6a\u4e91\u63d0\u4f9b\u9ad8\u6027\u80fd\u7684\u9999\u6e2f\u670d\u52a1\u5668\uff0c\u4ee5\u53ca\u5176\u4ed6\u591a\u79cd\u670d\u52a1\u5668\u9009\u62e9\u3002\u8bf7\u8bbf\u95ee\u6211\u4eec\u7684\u5b98\u7f51\u4e86\u89e3\u66f4\u591a\u4fe1\u606f\uff1a<a href=\"https:\/\/idc.net\">https:\/\/idc.net<\/a><\/p>\n","protected":false},"excerpt":{"rendered":"<p>WordPress\u63d2\u4ef6: Post Type Switcher WordPress\u662f\u4e00\u4e2a\u529f\u80fd\u5f3a\u5927\u7684\u5185\u5bb9\u7ba1\u7406\u7cfb\u7edf [&hellip;]<\/p>\n","protected":false},"author":1,"featured_media":0,"comment_status":"","ping_status":"","sticky":false,"template":"","format":"standard","meta":{"footnotes":""},"categories":[48],"tags":[],"class_list":["post-210182","post","type-post","status-publish","format-standard","hentry","category-wordpress"],"_links":{"self":[{"href":"https:\/\/idc.net\/help\/wp-json\/wp\/v2\/posts\/210182","targetHints":{"allow":["GET"]}}],"collection":[{"href":"https:\/\/idc.net\/help\/wp-json\/wp\/v2\/posts"}],"about":[{"href":"https:\/\/idc.net\/help\/wp-json\/wp\/v2\/types\/post"}],"author":[{"embeddable":true,"href":"https:\/\/idc.net\/help\/wp-json\/wp\/v2\/users\/1"}],"replies":[{"embeddable":true,"href":"https:\/\/idc.net\/help\/wp-json\/wp\/v2\/comments?post=210182"}],"version-history":[{"count":0,"href":"https:\/\/idc.net\/help\/wp-json\/wp\/v2\/posts\/210182\/revisions"}],"wp:attachment":[{"href":"https:\/\/idc.net\/help\/wp-json\/wp\/v2\/media?parent=210182"}],"wp:term":[{"taxonomy":"category","embeddable":true,"href":"https:\/\/idc.net\/help\/wp-json\/wp\/v2\/categories?post=210182"},{"taxonomy":"post_tag","embeddable":true,"href":"https:\/\/idc.net\/help\/wp-json\/wp\/v2\/tags?post=210182"}],"curies":[{"name":"wp","href":"https:\/\/api.w.org\/{rel}","templated":true}]}}