{"id":2322,"date":"2025-06-11T00:49:10","date_gmt":"2025-06-10T16:49:10","guid":{"rendered":"https:\/\/www.zhaozhao123.cn\/wpcms\/wpdt\/2322.html"},"modified":"2025-06-11T00:49:10","modified_gmt":"2025-06-10T16:49:10","slug":"%e5%a6%82%e4%bd%95%e5%9c%a8-wordpress-%e4%b8%ad%e8%87%aa%e5%8a%a8%e6%95%b4%e7%90%86%e5%86%85%e5%ae%b9","status":"publish","type":"post","link":"https:\/\/www.zhaozhao123.cn\/wpcms\/post\/2322.html","title":{"rendered":"\u5982\u4f55\u5728 WordPress \u4e2d\u81ea\u52a8\u6574\u7406\u5185\u5bb9"},"content":{"rendered":"<div class=\"wp-block-columns p-0 border is-layout-flex wp-container-core-columns-is-layout-28f84493 wp-block-columns-is-layout-flex\">\r\n<div class=\"wp-block-column is-layout-flow wp-block-column-is-layout-flow\">\r\n<div class=\"wp-block-columns px-4 py-3 border-bottom has-background is-layout-flex wp-container-core-columns-is-layout-28f84493 wp-block-columns-is-layout-flex\" style=\"background:linear-gradient(243deg,rgb(238,238,238) 0%,rgba(58,166,242,0.15) 100%)\">\r\n<div class=\"wp-block-column is-layout-flow wp-block-column-is-layout-flow\">\r\n<div class=\"wp-block-group is-nowrap is-layout-flex wp-container-core-group-is-layout-6c531013 wp-block-group-is-layout-flex\">\r\n<figure class=\"wp-block-image size-thumbnail is-resized is-style-rounded is-style-rounded--1\"><img decoding=\"async\" src=\"https:\/\/www.zhaozhao123.cn\/myitems\/images\/sites16\/2025\/06\/dyA-1-400x300.jpg\" alt=\"Bug&#32534;&#35793;&#29422;\" class=\"wp-image-1842\" style=\"object-fit:cover;width:30px;height:30px\"><\/figure>\r\n\r\n\r\n\r\n<p class=\"my-0\">Bug&#32534;&#35793;&#29422;<\/p>\r\n<\/div>\r\n<\/div>\r\n<\/div>\r\n\r\n\r\n\r\n<div class=\"wp-block-columns px-xl-5 px-4 py-xl-4 py-3 is-layout-flex wp-container-core-columns-is-layout-28f84493 wp-block-columns-is-layout-flex\">\r\n<div class=\"wp-block-column is-layout-flow wp-block-column-is-layout-flow\">\r\n<p>&#35201;&#20026;&#24744;&#30340; WordPress &#32593;&#31449;&#33258;&#21160;&#25972;&#29702;&#20869;&#23481;&#65292;&#25105;&#20204;&#21487;&#20197;&#20351;&#29992;&#19968;&#20123;&#25554;&#20214;&#21644;&#21151;&#33021;&#26469;&#23454;&#29616;&#33258;&#21160;&#21270;&#22788;&#29702;&#12290;&#19979;&#38754;&#25105;&#23558;&#20171;&#32461;&#19968;&#31181;&#24120;&#35265;&#30340;&#26041;&#27861;&#65292;&#21363;&#20351;&#29992; WP Auto Post and Rewrite &#26469;&#31649;&#29702;&#39029;&#38754;&#21644;&#25991;&#31456;&#30340;&#21457;&#24067;&#26085;&#26399;&#12290;<\/p>\n<h3>&#27493;&#39588; 1: &#23433;&#35013;&#24182;&#28608;&#27963;&#25554;&#20214;<\/h3>\n<p>&#39318;&#20808;&#65292;&#22312;&#24744;&#30340; WordPress &#31649;&#29702;&#38754;&#26495;&#20013;&#25214;&#21040;&ldquo;&#25554;&#20214;&rdquo;&#37096;&#20998;&#65292;&#28857;&#20987;&ldquo;&#28155;&#21152;&#26032;&#25554;&#20214;&rdquo;&#12290;&#25628;&#32034;&#24182;&#23433;&#35013; <code>WP Auto Post &amp; Rewrite<\/code> &#25554;&#20214;&#12290;&#23433;&#35013;&#23436;&#25104;&#21518;&#65292;&#28608;&#27963;&#35813;&#25554;&#20214;&#12290;<\/p>\n<h3>&#27493;&#39588; 2: &#37197;&#32622;&#25554;&#20214;<\/h3>\n<ul>\n<li>\n<p><strong>&#35774;&#32622;&#21457;&#24067;&#26085;&#26399;<\/strong>&#65306;&#36827;&#20837;&#25554;&#20214;&#30340;&#35774;&#32622;&#30028;&#38754;&#65292;&#24744;&#21487;&#20197;&#22312;&#37027;&#37324;&#37197;&#32622;&#21738;&#20123;&#39029;&#38754;&#25110;&#25991;&#31456;&#24212;&#35813;&#26681;&#25454;&#29305;&#23450;&#30340;&#26085;&#26399;&#33258;&#21160;&#26356;&#26032;&#12290;<\/p>\n<ul>\n<li>\n<p>&#22312;&#24038;&#20391;&#33756;&#21333;&#26639;&#36873;&#25321;&ldquo;&#33258;&#23450;&#20041;&rdquo;&#65292;&#28982;&#21518;&#36873;&#25321;&ldquo;&#33258;&#23450;&#20041;&#23383;&#27573;&rdquo;&#12290;<\/p>\n<\/li>\n<li>\n<p>&#21019;&#24314;&#19968;&#20010;&#26032;&#30340;&#33258;&#23450;&#20041;&#23383;&#27573;&#31867;&#22411;&#65292;&#20363;&#22914;&ldquo;&#33258;&#21160;&#21457;&#24067;&#26085;&#26399;&rdquo;&#12290;<\/p>\n<\/li>\n<li>\n<p>&#36827;&#20837;&#21491;&#20391;&#32534;&#36753;&#21306;&#22495;&#65292;&#24744;&#21487;&#20197;&#36755;&#20837;&#36825;&#20123;&#23383;&#27573;&#30340;&#20540;&#65288;&#22914;&#65306;2023-04-01&#65289;&#12290;<\/p>\n<\/li>\n<\/ul>\n<\/li>\n<\/ul>\n<h3>&#27493;&#39588; 3: &#20351;&#29992;&#31034;&#20363;&#20195;&#30721;<\/h3>\n<p>&#20551;&#35774;&#25105;&#20204;&#24076;&#26395;&#33258;&#21160;&#23558;&#25152;&#26377;&#26631;&#39064;&#20026; &#8220;Special Offer&#8221; &#30340;&#25991;&#31456;&#22312; 2023 &#24180; 5 &#26376; 1 &#26085;&#20043;&#21518;&#21457;&#24067;&#12290;&#25105;&#20204;&#38656;&#35201;&#21019;&#24314;&#19968;&#20010;&#33258;&#23450;&#20041;&#23383;&#27573;&#24182;&#23558;&#36825;&#20010;&#26085;&#26399;&#19982;&#25991;&#31456;&#20851;&#32852;&#36215;&#26469;&#12290;<\/p>\n<pre><code class=\"language-php\">\/\/ &#20551;&#35774;&#36825;&#26159;&#24744;&#30340;&#25991;&#31456;&#27169;&#26495;\nfunction auto_post_and_rewrite() {\n    $date = date('Y-m-d'); \/\/ &#33719;&#21462;&#24403;&#21069;&#26085;&#26399;&#20316;&#20026;&#40664;&#35748;&#21457;&#24067;&#26085;&#26399;\n    if (get_field('special_offer_date')) { \/\/ &#26816;&#26597;&#26159;&#21542;&#35774;&#32622;&#20102;&#33258;&#21160;&#21457;&#24067;&#30340;&#26085;&#26399;\n        $date = get_field('special_offer_date');\n    }\n\n    update_post_meta(get_the_ID(), 'auto_post', true); \/\/ &#26356;&#26032;&#25991;&#31456;&#30340;&#33258;&#21160;&#21457;&#24067;&#29366;&#24577;\n\n    $post_status = wp_cache_get('status_' . get_the_ID());\n    if ($post_status === false) {\n        $post_status = 'publish'; \/\/ &#40664;&#35748;&#29366;&#24577;&#20026;&#24050;&#21457;&#24067;\n    }\n    update_post_meta(get_the_ID(), '_wp_page_template', 'page.php'); \/\/ &#35774;&#32622;&#27169;&#26495;&#20026; page.php\n    update_post_meta(get_the_ID(), '_wp_auto_post', $date); \/\/ &#26356;&#26032;&#33258;&#23450;&#20041;&#23383;&#27573;&#20013;&#30340;&#33258;&#21160;&#21457;&#24067;&#26085;&#26399;\n\n    return;\n}\n\nadd_action( 'save_post', 'auto_post_and_rewrite' );<\/code><\/pre>\n<h3>&#27493;&#39588; 4: &#27979;&#35797;<\/h3>\n<p>&#30830;&#20445;&#24744;&#30340;&#25991;&#31456;&#26631;&#39064;&#20026; &ldquo;Special Offer&rdquo; &#30340;&#25991;&#31456;&#22312;&#20854;&#23545;&#24212;&#30340;&#26085;&#26399;&#20043;&#21518;&#21457;&#24067;&#12290;&#22914;&#26524;&#19968;&#20999;&#27491;&#24120;&#65292;&#24744;&#20250;&#30475;&#21040;&#25991;&#31456;&#26631;&#39064;&#21069;&#26377;&ldquo;*&rdquo;&#26631;&#35760;&#65292;&#34920;&#31034;&#23427;&#24050;&#32463;&#34987;&#33258;&#21160;&#21457;&#24067;&#20102;&#12290;<\/p>\n<h3>&#24635;&#32467;<\/h3>\n<p>&#36890;&#36807;&#19978;&#36848;&#27493;&#39588;&#65292;&#24744;&#21487;&#20197;&#36731;&#26494;&#22320;&#22312; WordPress &#20013;&#21551;&#29992;&#33258;&#21160;&#25972;&#29702;&#21151;&#33021;&#12290;&#36825;&#19981;&#20165;&#25552;&#39640;&#20102;&#32593;&#31449;&#20869;&#23481;&#30340;&#32452;&#32455;&#24615;&#65292;&#36824;&#33410;&#30465;&#20102;&#25163;&#21160;&#25805;&#20316;&#30340;&#26102;&#38388;&#12290;&#35831;&#35760;&#24471;&#23450;&#26399;&#26816;&#26597;&#24744;&#30340;&#33258;&#23450;&#20041;&#23383;&#27573;&#20197;&#30830;&#20445;&#23427;&#20204;&#20173;&#28982;&#31526;&#21512;&#39044;&#26399;&#30340;&#21457;&#24067;&#26102;&#38388;&#35268;&#21017;&#12290;<\/p>\r\n<\/div>\r\n<\/div>\r\n<\/div>\r\n<\/div><div class=\"wp-block-columns p-0 border is-layout-flex wp-container-core-columns-is-layout-28f84493 wp-block-columns-is-layout-flex\">\r\n<div class=\"wp-block-column is-layout-flow wp-block-column-is-layout-flow\">\r\n<div class=\"wp-block-columns px-4 py-3 border-bottom has-background is-layout-flex wp-container-core-columns-is-layout-28f84493 wp-block-columns-is-layout-flex\" style=\"background:linear-gradient(243deg,rgb(238,238,238) 0%,rgba(58,166,242,0.15) 100%)\">\r\n<div class=\"wp-block-column is-layout-flow wp-block-column-is-layout-flow\">\r\n<div class=\"wp-block-group is-nowrap is-layout-flex wp-container-core-group-is-layout-6c531013 wp-block-group-is-layout-flex\">\r\n<figure class=\"wp-block-image size-thumbnail is-resized is-style-rounded is-style-rounded--2\"><img decoding=\"async\" src=\"https:\/\/www.zhaozhao123.cn\/myitems\/images\/sites16\/2025\/06\/zp-400x300.jpg\" alt=\"&#40657;&#26495;&#21069;&#30340;Bug&#35821;&#27861;&#35762;&#24072;\" class=\"wp-image-1849\" style=\"object-fit:cover;width:30px;height:30px\"><\/figure>\r\n\r\n\r\n\r\n<p class=\"my-0\">&#40657;&#26495;&#21069;&#30340;Bug&#35821;&#27861;&#35762;&#24072;<\/p>\r\n<\/div>\r\n<\/div>\r\n<\/div>\r\n\r\n\r\n\r\n<div class=\"wp-block-columns px-xl-5 px-4 py-xl-4 py-3 is-layout-flex wp-container-core-columns-is-layout-28f84493 wp-block-columns-is-layout-flex\">\r\n<div class=\"wp-block-column is-layout-flow wp-block-column-is-layout-flow\">\r\n<p>&#22312;WordPress&#20013;&#65292;&#21487;&#20197;&#20351;&#29992;&#22810;&#31181;&#26041;&#27861;&#26469;&#33258;&#21160;&#25972;&#29702;&#21644;&#31649;&#29702;&#20869;&#23481;&#12290;&#20197;&#19979;&#26159;&#19968;&#20123;&#22522;&#26412;&#27493;&#39588;&#21644;&#31034;&#20363;&#20195;&#30721;&#65306;<\/p>\n<h3>1. &#20351;&#29992;&#33258;&#21160;&#25554;&#20214;&#65288;&#22914;WPML&#65289;<\/h3>\n<p><strong>&#21407;&#29702;<\/strong>: &#33258;&#21160;&#25554;&#20214;&#21487;&#20197;&#24110;&#21161;&#20320;&#20174;&#32593;&#31449;&#19978;&#25910;&#38598;&#25991;&#31456;&#25110;&#39029;&#38754;&#65292;&#24182;&#23558;&#20854;&#23384;&#20648;&#21040;&#25968;&#25454;&#24211;&#20013;&#65292;&#20197;&#20415;&#20110;&#32534;&#36753;&#12289;&#25628;&#32034;&#21644;&#21457;&#24067;&#12290;<\/p>\n<h4>&#31034;&#20363;&#20195;&#30721;&#65306;<\/h4>\n<pre><code class=\"language-php\">\/\/ &#20551;&#35774;&#25105;&#20204;&#26377;&#19968;&#20010;&#21517;&#20026;`content.php`&#30340;&#25991;&#20214;&#65292;&#23427;&#21253;&#21547;&#25105;&#20204;&#30340;&#25991;&#31456;&#21015;&#34920;&#12290;\n&lt;?php\nif (function_exists('acf_add_local_field_group')) {\n    acf_add_local_field_group(array(\n        'key' =&gt; 'group_5a03942768b5c',\n        'title' =&gt; 'Content Group Title',\n        'fields' =&gt; array(\n            array(\n                'key' =&gt; 'field_5a03942868b5d',\n                'label' =&gt; 'Title',\n                'name' =&gt; 'field_title',\n                'type' =&gt; 'text',\n                'instructions' =&gt; '',\n                'required' =&gt; 1,\n                'conditional_logic' =&gt; 0,\n                'wrapper' =&gt; array(\n                    'width' =&gt; '',\n                    'class' =&gt; '',\n                    'id' =&gt; ''\n                ),\n                'maxlength' =&gt; '',\n                'default_value' =&gt; '',\n                'placeholder' =&gt; '',\n                'prepend' =&gt; '',\n                'append' =&gt; '',\n                'insert_at_end_of_post' =&gt; 0,\n                'allow_null' =&gt; 0,\n                'source' =&gt; '',\n                'ui' =&gt; 0,\n                'message' =&gt; '',\n                'constant' =&gt; 0,\n                'show_on_screen' =&gt; 0,\n                'number_format' =&gt; '',\n                'reference' =&gt; '',\n                'multiselect' =&gt; '',\n                'save_also' =&gt; 0,\n                'ajax' =&gt; 0,\n                'return_format' =&gt; '',\n                'sub_fields' =&gt; array(),\n            ),\n        ),\n        'location' =&gt; array(\n            array(\n                array(\n                    array(\n                        'param' =&gt; 'post_type',\n                        'operator' =&gt; '==',\n                        'value' =&gt; 'your_post_type'\n                    ),\n                ),\n            ),\n        ),\n        'menu_order' =&gt; 0,\n        'position' =&gt; 'normal',\n        'style' =&gt; 'default',\n        'label_placement' =&gt; 'top',\n        'instruction_placement' =&gt; 'label',\n        '_ui' =&gt; true,\n    ));\n}<\/code><\/pre>\n<h3>2. &#20351;&#29992;&#33258;&#21160;&#21457;&#24067;&#21151;&#33021;&#65288;&#22914;WordPress REST API&#65289;<\/h3>\n<p><strong>&#21407;&#29702;<\/strong>: &#20351;&#29992;WordPress REST API&#21487;&#20197;&#20174;&#32593;&#31449;&#19978;&#25552;&#21462;&#25968;&#25454;&#24182;&#21457;&#24067;&#23427;&#20204;&#12290;<\/p>\n<h4>&#31034;&#20363;&#20195;&#30721;&#65306;<\/h4>\n<pre><code class=\"language-php\">$rest = new WP_REST_Server();\n$rest-&gt;register_routes(new WP_Rest_Controller());\n$rest-&gt;register_routes(new WP_Rest_Plugin_Controller());\n\n\/\/ &#33719;&#21462;&#25991;&#31456;&#21015;&#34920;\n$post_types = get_posts(array(\n    'post_type' =&gt; 'your_post_type',\n));\n\n\/\/ &#21457;&#24067;&#25991;&#31456;\nforeach ($post_types as $post) {\n    wp_publish_post($post);\n}\n\n\/\/ &#21024;&#38500;&#26087;&#30340;&#25991;&#31456;\nwp_delete_posts(array(\n    'post_status' =&gt; 'publish',\n));<\/code><\/pre>\n<h3>3. &#20351;&#29992;&#20027;&#39064;&#25554;&#20214;<\/h3>\n<p><strong>&#21407;&#29702;<\/strong>: &#20027;&#39064;&#25554;&#20214;&#21487;&#20197;&#33258;&#23450;&#20041;WordPress&#30340;&#30028;&#38754;&#21644;&#21151;&#33021;&#12290;<\/p>\n<h4>&#31034;&#20363;&#20195;&#30721;&#65306;<\/h4>\n<pre><code class=\"language-html\">&lt;!DOCTYPE html&gt;\n&lt;html&gt;\n&lt;head&gt;\n    &lt;meta charset=\"UTF-8\"&gt;\n    &lt;title&gt;Your WordPress Theme&lt;\/title&gt;\n    &lt;link rel=\"stylesheet\" href=\"&lt;?php echo get_template_directory_uri(); ?&gt;\/style.css\"\/&gt;\n    &lt;?php wp_head(); ?&gt;\n&lt;\/head&gt;\n\n&lt;body&gt;\n    &lt;h1&gt;Welcome to Your WordPress Theme!&lt;\/h1&gt;\n    &lt;?php if (have_posts()) : while (have_posts()) : the_post(); ?&gt;\n        &lt;div&gt;&lt;?php the_content(); ?&gt;&lt;\/div&gt;\n    &lt;?php endwhile; endif; ?&gt;\n&lt;\/body&gt;\n&lt;\/html&gt;<\/code><\/pre>\n<p>&#36890;&#36807;&#19978;&#36848;&#31034;&#20363;&#65292;&#20320;&#21487;&#20197;&#20102;&#35299;&#22914;&#20309;&#20351;&#29992;WordPress&#33258;&#21160;&#25972;&#29702;&#21644;&#31649;&#29702;&#20869;&#23481;&#30340;&#26041;&#27861;&#12290;&#19981;&#21516;&#30340;&#24773;&#20917;&#21487;&#33021;&#38656;&#35201;&#36873;&#25321;&#21512;&#36866;&#30340;&#25554;&#20214;&#25110;&#21151;&#33021;&#32452;&#21512;&#65292;&#20197;&#28385;&#36275;&#29305;&#23450;&#38656;&#27714;&#12290;<\/p>\r\n<\/div>\r\n<\/div>\r\n<\/div>\r\n<\/div>\n","protected":false},"excerpt":{"rendered":"<p>Bug&#32534;&#35793;&#29422; &#35201;&#20026;&#24744;&#30340; WordPress &#32593;&#31449;&#33258;&#21160;&#25972;&#29702;&#20869;&#23481;&#65292;&#25105;&#20204;&#038;..<\/p>\n","protected":false},"author":1,"featured_media":0,"comment_status":"","ping_status":"","sticky":false,"template":"","format":"standard","meta":{"_acf_changed":false,"footnotes":""},"categories":[1],"tags":[59],"tuisongtax":[],"class_list":["post-2322","post","type-post","status-publish","format-standard","hentry","category-wpdt","tag-pzjc"],"acf":[],"_links":{"self":[{"href":"https:\/\/www.zhaozhao123.cn\/wpcms\/wp-json\/wp\/v2\/posts\/2322","targetHints":{"allow":["GET"]}}],"collection":[{"href":"https:\/\/www.zhaozhao123.cn\/wpcms\/wp-json\/wp\/v2\/posts"}],"about":[{"href":"https:\/\/www.zhaozhao123.cn\/wpcms\/wp-json\/wp\/v2\/types\/post"}],"author":[{"embeddable":true,"href":"https:\/\/www.zhaozhao123.cn\/wpcms\/wp-json\/wp\/v2\/users\/1"}],"replies":[{"embeddable":true,"href":"https:\/\/www.zhaozhao123.cn\/wpcms\/wp-json\/wp\/v2\/comments?post=2322"}],"version-history":[{"count":0,"href":"https:\/\/www.zhaozhao123.cn\/wpcms\/wp-json\/wp\/v2\/posts\/2322\/revisions"}],"wp:attachment":[{"href":"https:\/\/www.zhaozhao123.cn\/wpcms\/wp-json\/wp\/v2\/media?parent=2322"}],"wp:term":[{"taxonomy":"category","embeddable":true,"href":"https:\/\/www.zhaozhao123.cn\/wpcms\/wp-json\/wp\/v2\/categories?post=2322"},{"taxonomy":"post_tag","embeddable":true,"href":"https:\/\/www.zhaozhao123.cn\/wpcms\/wp-json\/wp\/v2\/tags?post=2322"},{"taxonomy":"tuisongtax","embeddable":true,"href":"https:\/\/www.zhaozhao123.cn\/wpcms\/wp-json\/wp\/v2\/tuisongtax?post=2322"}],"curies":[{"name":"wp","href":"https:\/\/api.w.org\/{rel}","templated":true}]}}