{"id":3095,"date":"2025-06-11T17:50:55","date_gmt":"2025-06-11T09:50:55","guid":{"rendered":"https:\/\/www.zhaozhao123.cn\/wpcms\/wpdt\/3095.html"},"modified":"2025-06-11T17:50:55","modified_gmt":"2025-06-11T09:50:55","slug":"%e5%a6%82%e4%bd%95%e5%9c%a8wordpress%e4%b8%ad%e5%88%9b%e5%bb%ba%e5%b8%a6%e6%9c%89%e4%b8%8b%e6%8b%89%e8%8f%9c%e5%8d%95%e5%ad%97%e6%ae%b5%e7%9a%84%e8%a1%a8%e5%8d%95%ef%bc%88%e7%ae%80%e5%8d%95%e6%96%b9","status":"publish","type":"post","link":"https:\/\/www.zhaozhao123.cn\/wpcms\/post\/3095.html","title":{"rendered":"\u5982\u4f55\u5728WordPress\u4e2d\u521b\u5efa\u5e26\u6709\u4e0b\u62c9\u83dc\u5355\u5b57\u6bb5\u7684\u8868\u5355\uff08\u7b80\u5355\u65b9\u6cd5\uff09"},"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;&#22312;WordPress&#20013;&#21019;&#24314;&#24102;&#26377;&#19979;&#25289;&#33756;&#21333;&#23383;&#27573;&#30340;&#34920;&#21333;&#65292;&#20320;&#21487;&#20197;&#20351;&#29992;&#25554;&#20214;&#25110;&#36890;&#36807;&#33258;&#23450;&#20041;&#20195;&#30721;&#26469;&#23454;&#29616;&#12290;&#20197;&#19979;&#26159;&#20004;&#31181;&#24120;&#35265;&#30340;&#26041;&#27861;&#65306;<\/p>\n<h3>&#26041;&#27861;&#19968;&#65306;&#20351;&#29992;&#20869;&#32622;&#21151;&#33021;<\/h3>\n<h4>&#27493;&#39588;&#65306;<\/h4>\n<ol>\n<li><strong>&#30331;&#24405;&#21040;&#24744;&#30340;WordPress&#21518;&#21488;<\/strong>&#12290;<\/li>\n<li>&#23548;&#33322;&#21040;&ldquo;&#35774;&#32622;&rdquo; &gt; &ldquo;&#36890;&#29992;&rdquo;&#12290;<\/li>\n<li>&#22312;&ldquo;&#34920;&#21333;&rdquo;&#37096;&#20998;&#65292;&#28857;&#20987;&ldquo;&#28155;&#21152;&#26032;&#34920;&#21333;&rdquo;&#25353;&#38062;&#12290;<\/li>\n<li>&#36873;&#25321;&#19968;&#20010;&#27169;&#26495;&#65292;&#20363;&#22914;&ldquo;&#26631;&#20934;&#34920;&#21333;&rdquo;&#65292;&#28982;&#21518;&#32487;&#32493;&#21521;&#21491;&#28378;&#21160;&#25214;&#21040;&ldquo;&#38468;&#21152;&#23383;&#27573;&rdquo;&#36873;&#39033;&#21345;&#12290;<\/li>\n<li>&#22312;&ldquo;&#38468;&#21152;&#23383;&#27573;&rdquo;&#36873;&#39033;&#21345;&#20013;&#65292;&#28857;&#20987;&ldquo;&#28155;&#21152;&#23383;&#27573;&rdquo;&#20197;&#28155;&#21152;&#19968;&#20010;&#26032;&#30340;&#23383;&#27573;&#31867;&#22411;&#12290;<\/li>\n<\/ol>\n<h4>&#31034;&#20363;&#20195;&#30721;&#65306;<\/h4>\n<pre><code class=\"language-php\">\/\/ &#20551;&#35774;&#20320;&#38656;&#35201;&#21019;&#24314;&#19968;&#20010;&#19979;&#25289;&#33756;&#21333;&#23383;&#27573;&#65292;&#20854;&#20013;&#21253;&#21547;&#19977;&#20010;&#36873;&#39033;&#65306;A, B, C\nfunction add_custom_field() {\n    $args = array(\n        'type' =&gt; 'select',\n        'label' =&gt; '&#35831;&#36873;&#25321;&#36873;&#39033;',\n        'name' =&gt; 'custom_field_name', \/\/ &#36825;&#37324;&#26159;&#20320;&#30340;&#23383;&#27573;&#21517;&#31216;\n        'options' =&gt; array(\n            'option_a' =&gt; '&#36873;&#39033;A',\n            'option_b' =&gt; '&#36873;&#39033;B',\n            'option_c' =&gt; '&#36873;&#39033;C'\n        )\n    );\n\n    echo wpforms_form_start($args);\n}<\/code><\/pre>\n<h3>&#26041;&#27861;&#20108;&#65306;&#20351;&#29992;&#31532;&#19977;&#26041;&#25554;&#20214;<\/h3>\n<p>&#26377;&#35768;&#22810;&#25554;&#20214;&#21487;&#20197;&#25552;&#20379;&#26356;&#20016;&#23500;&#30340;&#34920;&#21333;&#21151;&#33021;&#65292;&#21253;&#25324;&#19979;&#25289;&#33756;&#21333;&#23383;&#27573;&#12290;&#20197;&#19979;&#26159;&#19968;&#20123;&#25512;&#33616;&#30340;&#25554;&#20214;&#65306;<\/p>\n<ul>\n<li><strong>WPForms<\/strong>: &#25552;&#20379;&#20102;&#24378;&#22823;&#30340;&#34920;&#21333;&#29983;&#25104;&#21644;&#23450;&#21046;&#33021;&#21147;&#65292;&#21253;&#25324;&#19979;&#25289;&#33756;&#21333;&#23383;&#27573;&#12290;<\/li>\n<li><strong>Formidable Forms<\/strong>: &#20855;&#26377;&#29992;&#25143;&#21451;&#22909;&#30340;&#30028;&#38754;&#21644;&#39640;&#32423;&#21151;&#33021;&#65292;&#22914;&#19979;&#25289;&#33756;&#21333;&#12289;&#22797;&#36873;&#26694;&#31561;&#12290;<\/li>\n<\/ul>\n<h4>&#27493;&#39588;&#65306;<\/h4>\n<ol>\n<li>&#30331;&#24405;&#21040;WordPress&#21518;&#21488;&#12290;<\/li>\n<li>&#25214;&#21040;&#24182;&#23433;&#35013;&#24744;&#21916;&#27426;&#30340;&#25554;&#20214;&#65292;&#20363;&#22914;&ldquo;WPForms&rdquo;&#25110;&ldquo;Formidable Forms&rdquo;&#12290;<\/li>\n<li>&#21551;&#29992;&#25554;&#20214;&#21518;&#65292;&#26681;&#25454;&#25351;&#31034;&#37197;&#32622;&#34920;&#21333;&#12290;<\/li>\n<li>&#20351;&#29992;&#25554;&#20214;&#25552;&#20379;&#30340;&#24037;&#20855;&#28155;&#21152;&#19979;&#25289;&#33756;&#21333;&#23383;&#27573;&#21644;&#20854;&#20182;&#25152;&#38656;&#23383;&#27573;&#12290;<\/li>\n<\/ol>\n<h4>&#31034;&#20363;&#20195;&#30721;&#65306;<\/h4>\n<p>&#20551;&#35774;&#25105;&#20204;&#36873;&#25321;&#20102;&ldquo;WPForms&rdquo;&#25554;&#20214;&#65306;<\/p>\n<ol>\n<li>&#23433;&#35013;&#24182;&#21551;&#29992;WPForms&#25554;&#20214;&#12290;<\/li>\n<li>&#21019;&#24314;&#26032;&#30340;&#34920;&#21333;&#12290;<\/li>\n<li>&#28155;&#21152;&#23383;&#27573;&#26102;&#65292;&#36873;&#25321;&ldquo;&#19979;&#25289;&#33756;&#21333;&rdquo;&#20316;&#20026;&#23383;&#27573;&#31867;&#22411;&#12290;<\/li>\n<li>&#35774;&#32622;&#23383;&#27573;&#21517;&#21644;&#36873;&#39033;&#21015;&#34920;&#12290;<\/li>\n<\/ol>\n<h3>&#25928;&#26524;&#35828;&#26126;&#65306;<\/h3>\n<p>&#26080;&#35770;&#20351;&#29992;&#21738;&#31181;&#26041;&#27861;&#65292;&#24403;&#29992;&#25143;&#22635;&#20889;&#34920;&#21333;&#26102;&#65292;&#20182;&#20204;&#21487;&#20197;&#36873;&#25321;&#20174;&#39044;&#35774;&#30340;&#19979;&#25289;&#33756;&#21333;&#36873;&#39033;&#20013;&#36873;&#25321;&#19968;&#20010;&#20540;&#12290;&#36825;&#20026;&#29992;&#25143;&#25552;&#20379;&#20102;&#19968;&#20010;&#26041;&#20415;&#30340;&#26041;&#24335;&#26469;&#36755;&#20837;&#29305;&#23450;&#30340;&#20449;&#24687;&#65292;&#32780;&#26080;&#38656;&#25163;&#21160;&#36755;&#20837;&#25991;&#26412;&#12290;<\/p>\n<p>&#24076;&#26395;&#36825;&#20123;&#20449;&#24687;&#23545;&#20320;&#26377;&#25152;&#24110;&#21161;&#65281;&#22914;&#26524;&#20320;&#26377;&#20219;&#20309;&#20854;&#20182;&#38382;&#39064;&#65292;&#35831;&#38543;&#26102;&#25552;&#38382;&#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;&#21019;&#24314;&#24102;&#26377;&#19979;&#25289;&#33756;&#21333;&#23383;&#27573;&#30340;&#34920;&#21333;&#26159;&#19968;&#31181;&#24120;&#35265;&#30340;&#38656;&#27714;&#65292;&#29305;&#21035;&#26159;&#24403;&#38656;&#35201;&#25552;&#20379;&#22810;&#31181;&#36873;&#25321;&#25110;&#20801;&#35768;&#29992;&#25143;&#20174;&#19968;&#20010;&#36873;&#39033;&#21015;&#34920;&#20013;&#36827;&#34892;&#36873;&#25321;&#26102;&#12290;&#20197;&#19979;&#26159;&#22914;&#20309;&#20351;&#29992;&#31616;&#21333;&#30340;PHP&#21644;HTML&#26469;&#23454;&#29616;&#36825;&#19968;&#21151;&#33021;&#12290;<\/p>\n<h3>1. &#21019;&#24314;&#34920;&#21333;<\/h3>\n<p>&#39318;&#20808;&#65292;&#20320;&#38656;&#35201;&#22312;&#19968;&#20010;WordPress&#20027;&#39064;&#25110;&#25554;&#20214;&#20013;&#21019;&#24314;&#19968;&#20010;&#21253;&#21547;&#19979;&#25289;&#33756;&#21333;&#23383;&#27573;&#30340;&#34920;&#21333;&#12290;&#20551;&#35774;&#25105;&#20204;&#26377;&#19968;&#20010;&#21517;&#20026;&ldquo;contact-form&rdquo;&#30340;&#34920;&#21333;&#65292;&#29992;&#20110;&#25910;&#38598;&#29992;&#25143;&#20449;&#24687;&#65306;<\/p>\n<pre><code class=\"language-php\">&lt;?php if (have_posts()) : while (have_posts()) : the_post(); ?&gt;\n    &lt;form action=\"&lt;?php echo esc_url(esc_url(get_field('contact_form_action'))); ?&gt;\" method=\"post\"&gt;\n        &lt;?php wp_nonce_field(basename(__FILE__)); ?&gt;\n        &lt;label for=\"name\"&gt;Name:&lt;\/label&gt;\n        &lt;input type=\"text\" id=\"name\" name=\"name\" placeholder=\"Enter your name\" required&gt;\n\n        &lt;label for=\"email\"&gt;Email:&lt;\/label&gt;\n        &lt;input type=\"email\" id=\"email\" name=\"email\" placeholder=\"Enter your email address\" required&gt;\n\n        &lt;label for=\"phone\"&gt;Phone:&lt;\/label&gt;\n        &lt;input type=\"tel\" id=\"phone\" name=\"phone\" pattern=\"[0-9]{3}-[0-9]{2}-[0-9]{3}\" placeholder=\"Enter your phone number\" required&gt;\n\n        &lt;div class=\"select-field\"&gt;\n            &lt;label for=\"country\"&gt;Country:&lt;\/label&gt;\n            &lt;select id=\"country\" name=\"country\"&gt;\n                &lt;option value=\"\"&gt;Select a country...&lt;\/option&gt;\n                &lt;option value=\"usa\"&gt;United States&lt;\/option&gt;\n                &lt;option value=\"canada\"&gt;Canada&lt;\/option&gt;\n                &lt;option value=\"australia\"&gt;Australia&lt;\/option&gt;\n                &lt;!-- &#26356;&#22810;&#22269;&#23478;&#36873;&#39033; --&gt;\n            &lt;\/select&gt;\n        &lt;\/div&gt;\n\n        &lt;button type=\"submit\"&gt;Submit&lt;\/button&gt;\n    &lt;\/form&gt;\n&lt;?php endwhile; endif; ?&gt;<\/code><\/pre>\n<h3>2. &#20351;&#29992;jQuery&#21152;&#36733;&#19979;&#25289;&#33756;&#21333;<\/h3>\n<p>&#20026;&#20102;&#20351;&#19979;&#25289;&#33756;&#21333;&#26356;&#21152;&#32654;&#35266;&#24182;&#25903;&#25345;&#25302;&#25918;&#25928;&#26524;&#65292;&#21487;&#20197;&#20351;&#29992;jQuery&#24211;&#12290;&#36825;&#37324;&#26159;&#19968;&#20010;&#20363;&#23376;&#65306;<\/p>\n<pre><code class=\"language-html\">&lt;script src=\"https:\/\/code.jquery.com\/jquery-3.6.0.min.js\"&gt;&lt;\/script&gt;\n\n&lt;div class=\"select-field\"&gt;\n    &lt;label for=\"country\"&gt;Country:&lt;\/label&gt;\n    &lt;select id=\"country\" name=\"country\" multiple=\"multiple\"&gt;\n        &lt;option value=\"\" selected disabled hidden&gt;Select a country...&lt;\/option&gt;\n        &lt;option value=\"usa\"&gt;United States&lt;\/option&gt;\n        &lt;option value=\"canada\"&gt;Canada&lt;\/option&gt;\n        &lt;option value=\"australia\"&gt;Australia&lt;\/option&gt;\n        &lt;!-- &#26356;&#22810;&#22269;&#23478;&#36873;&#39033; --&gt;\n    &lt;\/select&gt;\n    &lt;a href=\"#\" data-select=\"country\"&gt;Drag and drop to add more options.&lt;\/a&gt;\n&lt;\/div&gt;\n\n&lt;script&gt;\n$(document).ready(function() {\n    $('#country').change(function(e) {\n        \/\/ Add or remove options dynamically based on the selected option\n        var selectedOption = $(this).find('option:selected');\n        var options = $(this).children('option');\n\n        if ($(this).val() !== '') {\n            \/\/ Remove any existing options before adding new ones\n            options.remove();\n        }\n\n        \/\/ Add the selected option's value as an option\n        options.append(selectedOption);\n\n        \/\/ Update the dropdown list with all available options\n        updateDropdownList(options);\n    });\n\n    function updateDropdownList(options) {\n        var selectedValue = $('#country').val();\n\n        $.each(options, function(index, option) {\n            if ($(option).data('selected') === true) {\n                $(option).attr('selected', 'selected');\n            } else {\n                $(option).removeAttr('selected');\n            }\n        });\n\n        \/\/ Set the selected value in the form field\n        $('#country').val(selectedValue);\n    }\n});\n&lt;\/script&gt;<\/code><\/pre>\n<h3>3. &#20351;&#29992;JavaScript&#28155;&#21152;&#19979;&#25289;&#33756;&#21333;<\/h3>\n<p>&#22914;&#26524;&#20320;&#24819;&#19981;&#20351;&#29992;jQuery&#65292;&#20063;&#21487;&#20197;&#36890;&#36807;JavaScript&#25163;&#21160;&#28155;&#21152;&#19979;&#25289;&#33756;&#21333;&#12290;&#36825;&#26159;&#19968;&#20010;&#22522;&#26412;&#30340;&#20363;&#23376;&#65306;<\/p>\n<pre><code class=\"language-javascript\">var selectField = document.getElementById(\"country\");\nvar options = [];\n\nfor (let i = 1; i &lt;= 50; i++) {\n    let option = document.createElement(\"option\");\n    option.value = i;\n    option.text = \"Option \" + i;\n    options.push(option);\n}\n\nselectField.appendChild(...options);<\/code><\/pre>\n<h3>&#25945;&#31243;&#24635;&#32467;<\/h3>\n<p>&#20197;&#19978;&#20195;&#30721;&#23637;&#31034;&#20102;&#22914;&#20309;&#22312;WordPress&#20013;&#21019;&#24314;&#19968;&#20010;&#20855;&#26377;&#19979;&#25289;&#33756;&#21333;&#30340;&#31616;&#21333;&#34920;&#21333;&#12290;&#20320;&#21487;&#20197;&#26681;&#25454;&#33258;&#24049;&#30340;&#38656;&#27714;&#35843;&#25972;&#36825;&#20123;&#31034;&#20363;&#20197;&#28385;&#36275;&#29305;&#23450;&#30340;&#39033;&#30446;&#38656;&#27714;&#12290;&#21516;&#26102;&#65292;&#30830;&#20445;&#36981;&#24490;WordPress&#30340;&#20027;&#39064;&#25351;&#21335;&#21644;&#26368;&#20339;&#23454;&#36341;&#65292;&#20197;&#20415;&#20805;&#20998;&#21033;&#29992;WordPress&#25552;&#20379;&#30340;&#21508;&#31181;&#24037;&#20855;&#21644;&#21151;&#33021;&#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;&#22312;WordPress&#20013;&#21019;&#24314;&#24102;&#26377;&#19979;&#25289;&#33756;&#21333;&#23383;&#27573;&#30340;&#34920;&#038;#2..<\/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":[2107,2106],"tuisongtax":[],"class_list":["post-3095","post","type-post","status-publish","format-standard","hentry","category-wpdt","tag-cjyy","tag-cjzn"],"acf":[],"_links":{"self":[{"href":"https:\/\/www.zhaozhao123.cn\/wpcms\/wp-json\/wp\/v2\/posts\/3095","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=3095"}],"version-history":[{"count":0,"href":"https:\/\/www.zhaozhao123.cn\/wpcms\/wp-json\/wp\/v2\/posts\/3095\/revisions"}],"wp:attachment":[{"href":"https:\/\/www.zhaozhao123.cn\/wpcms\/wp-json\/wp\/v2\/media?parent=3095"}],"wp:term":[{"taxonomy":"category","embeddable":true,"href":"https:\/\/www.zhaozhao123.cn\/wpcms\/wp-json\/wp\/v2\/categories?post=3095"},{"taxonomy":"post_tag","embeddable":true,"href":"https:\/\/www.zhaozhao123.cn\/wpcms\/wp-json\/wp\/v2\/tags?post=3095"},{"taxonomy":"tuisongtax","embeddable":true,"href":"https:\/\/www.zhaozhao123.cn\/wpcms\/wp-json\/wp\/v2\/tuisongtax?post=3095"}],"curies":[{"name":"wp","href":"https:\/\/api.w.org\/{rel}","templated":true}]}}