{"id":2369,"date":"2025-06-11T01:25:46","date_gmt":"2025-06-10T17:25:46","guid":{"rendered":"https:\/\/www.zhaozhao123.cn\/wpcms\/wpdt\/2369.html"},"modified":"2025-06-11T01:25:46","modified_gmt":"2025-06-10T17:25:46","slug":"%e5%a6%82%e4%bd%95%e5%9c%a8wordpress%e5%8c%ba%e5%9d%97%e4%b9%8b%e9%97%b4%e6%b7%bb%e5%8a%a0%e6%88%96%e5%88%a0%e9%99%a4%e7%a9%ba%e9%9a%99%ef%bc%88%e5%9b%9b%e7%a7%8d%e6%96%b9%e6%b3%95%ef%bc%89","status":"publish","type":"post","link":"https:\/\/www.zhaozhao123.cn\/wpcms\/post\/2369.html","title":{"rendered":"\u5982\u4f55\u5728WordPress\u533a\u5757\u4e4b\u95f4\u6dfb\u52a0\u6216\u5220\u9664\u7a7a\u9699\uff08\u56db\u79cd\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>&#22312;WordPress&#20013;&#65292;&#21306;&#22359;&#20043;&#38388;&#30340;&#38388;&#36317;&#21487;&#20197;&#36890;&#36807;&#22810;&#31181;&#26041;&#24335;&#26469;&#35843;&#25972;&#21644;&#25511;&#21046;&#12290;&#36825;&#37324;&#20171;&#32461;&#22235;&#31181;&#24120;&#35265;&#30340;&#26041;&#27861;&#65306;&#20351;&#29992;CSS&#26679;&#24335;&#12289;&#20462;&#25913;<code>style.css<\/code>&#25991;&#20214;&#12289;&#36890;&#36807;&#25554;&#20214;&#21644;&#33258;&#23450;&#20041;&#20989;&#25968;&#65292;&#20197;&#21450;&#21033;&#29992;Bootstrap&#26694;&#26550;&#30340;&#26629;&#26684;&#31995;&#32479;&#12290;&#19979;&#38754;&#25105;&#23558;&#36880;&#19968;&#35299;&#37322;&#36825;&#20123;&#26041;&#27861;&#12290;<\/p>\n<h3>&#26041;&#27861;&#19968;&#65306;&#20351;&#29992;CSS&#26679;&#24335;<\/h3>\n<h4>&#23454;&#29616;&#27493;&#39588;&#65306;<\/h4>\n<ol>\n<li>&#25171;&#24320;&#20320;&#30340;&#20027;&#39064;&#32534;&#36753;&#22120;&#12290;<\/li>\n<li>&#23548;&#33322;&#21040;<code>style.css<\/code>&#25991;&#20214;&#12290;<\/li>\n<li>&#22312;&#25991;&#20214;&#26411;&#23614;&#25214;&#21040;&#20197;&#19979;&#34892;&#65306;\n<pre><code class=\"language-css\">.element {\n   padding: 0;\n   margin: 0;\n}<\/code><\/pre><\/li>\n<li>&#23558;&#20197;&#19978;&#34892;&#26367;&#25442;&#20026;&#65306;\n<pre><code class=\"language-css\">.element {\n   padding: 20px; \/* &#35843;&#25972;&#31354;&#38553;&#22823;&#23567; *\/\n   margin: 0 auto; \/* &#22402;&#30452;&#23621;&#20013; *\/\n}<\/code><\/pre><\/li>\n<li>&#20445;&#23384;&#25991;&#20214;&#24182;&#21047;&#26032;&#39029;&#38754;&#26597;&#30475;&#25928;&#26524;&#12290;<\/li>\n<\/ol>\n<h4>&#25928;&#26524;&#35828;&#26126;&#65306;<\/h4>\n<p>&#36825;&#31181;&#26041;&#27861;&#31616;&#21333;&#24555;&#25463;&#65292;&#36866;&#29992;&#20110;&#25152;&#26377;&#21306;&#22359;&#20803;&#32032;&#12290;&#21482;&#38656;&#35774;&#32622;&#21512;&#36866;&#30340;<code>padding<\/code>&#20540;&#21363;&#21487;&#25913;&#21464;&#21306;&#22359;&#20043;&#38388;&#30340;&#36317;&#31163;&#12290;&#27492;&#26041;&#27861;&#19981;&#38656;&#35201;&#39069;&#22806;&#23433;&#35013;&#20219;&#20309;&#25554;&#20214;&#65292;&#36866;&#21512;&#21021;&#27425;&#25509;&#35302;CSS&#24067;&#23616;&#30340;&#26032;&#25163;&#12290;<\/p>\n<h3>&#26041;&#27861;&#20108;&#65306;&#20462;&#25913;<code>style.css<\/code><\/h3>\n<h4>&#23454;&#29616;&#27493;&#39588;&#65306;<\/h4>\n<ol>\n<li>&#30452;&#25509;&#25171;&#24320;<code>style.css<\/code>&#25991;&#20214;&#12290;<\/li>\n<li>&#22312;&#21512;&#36866;&#30340;&#20301;&#32622;&#28155;&#21152;&#26032;&#30340;CSS&#35268;&#21017;&#12290;&#20363;&#22914;&#65292;&#22914;&#26524;&#20320;&#24819;&#23545;&#25152;&#26377;&#30340;&#21306;&#22359;&#20803;&#32032;&#37117;&#24212;&#29992;&#30456;&#21516;&#30340;&#38388;&#36317;&#65292;&#21487;&#20197;&#22312;&#25991;&#20214;&#39030;&#37096;&#28155;&#21152;&#65306;\n<pre><code class=\"language-css\">.element {\n   padding: 20px;\n   margin: 0 auto;\n}<\/code><\/pre><\/li>\n<li>&#20445;&#23384;&#25991;&#20214;&#12290;<\/li>\n<\/ol>\n<h4>&#25928;&#26524;&#35828;&#26126;&#65306;<\/h4>\n<p>&#19982;&#31532;&#19968;&#31181;&#26041;&#27861;&#31867;&#20284;&#65292;&#36825;&#31181;&#26041;&#24335;&#20063;&#26159;&#36890;&#36807;&#20462;&#25913;&#20840;&#23616;&#30340;CSS&#35268;&#21017;&#26469;&#24433;&#21709;&#25152;&#26377;&#21306;&#22359;&#20803;&#32032;&#12290;&#36825;&#20351;&#24471;&#26356;&#25913;&#21464;&#24471;&#26356;&#20026;&#36890;&#29992;&#65292;&#20294;&#21487;&#33021;&#20250;&#24433;&#21709;&#21040;&#38750;&#21306;&#22359;&#20803;&#32032;&#30340;&#24067;&#23616;&#12290;<\/p>\n<h3>&#26041;&#27861;&#19977;&#65306;&#36890;&#36807;&#25554;&#20214;<\/h3>\n<h4>&#20351;&#29992;&ldquo;Elementor Pro&rdquo;&#25554;&#20214;<\/h4>\n<ol>\n<li>&#23433;&#35013;&#24182;&#28608;&#27963;&ldquo;Elementor Pro&rdquo;&#25554;&#20214;&#12290;<\/li>\n<li>&#21019;&#24314;&#19968;&#20010;&#26032;&#30340;&#21306;&#22359;&#25110;&#32534;&#36753;&#29616;&#26377;&#30340;&#21306;&#22359;&#12290;<\/li>\n<li>&#36873;&#25321;&ldquo;Style &gt; Padding &amp; Margins&rdquo;&#36873;&#39033;&#21345;&#12290;<\/li>\n<li>&#36755;&#20837;&#25152;&#38656;&#30340;&#36793;&#36317;&#20540;&#12290;<\/li>\n<li>&#28857;&#20987;&ldquo;Apply&rdquo;&#25353;&#38062;&#12290;<\/li>\n<li>&#20445;&#23384;&#21306;&#22359;&#12290;<\/li>\n<\/ol>\n<h4>&#25928;&#26524;&#35828;&#26126;&#65306;<\/h4>\n<p>&ldquo;Elementor Pro&rdquo;&#25552;&#20379;&#20102;&#20016;&#23500;&#30340;&#33258;&#23450;&#20041;&#21151;&#33021;&#65292;&#21253;&#25324;&#21306;&#22359;&#20869;&#21508;&#31181;&#36793;&#36317;&#21644;&#22635;&#20805;&#23646;&#24615;&#12290;&#36890;&#36807;&#36825;&#20010;&#25554;&#20214;&#65292;&#20320;&#21487;&#20197;&#36731;&#26494;&#22320;&#35843;&#25972;&#20219;&#24847;&#21306;&#22359;&#30340;&#38388;&#36317;&#65292;&#32780;&#26080;&#38656;&#20462;&#25913;&#27169;&#26495;&#25110;CSS&#25991;&#20214;&#12290;<\/p>\n<h3>&#26041;&#27861;&#22235;&#65306;&#20351;&#29992;Bootstrap&#26629;&#26684;&#31995;&#32479;<\/h3>\n<h4>&#23454;&#29616;&#27493;&#39588;&#65306;<\/h4>\n<ol>\n<li>&#22914;&#26524;&#20320;&#30340;&#20027;&#39064;&#25903;&#25345;Bootstrap&#26629;&#26684;&#31995;&#32479;&#65292;&#35831;&#30830;&#20445;&#24050;&#21551;&#29992;&#23427;&#12290;<\/li>\n<li>&#20462;&#25913;&#24744;&#30340;HTML&#32467;&#26500;&#20197;&#36866;&#24212;&#26629;&#26684;&#31995;&#32479;&#12290;&#20363;&#22914;&#65306;\n<pre><code class=\"language-html\">&lt;div class=\"row\"&gt;\n   &lt;div class=\"col-md-6\"&gt;&#24038;&#21015;&lt;\/div&gt;\n   &lt;div class=\"col-md-6\"&gt;&#21491;&#21015;&lt;\/div&gt;\n&lt;\/div&gt;<\/code><\/pre><\/li>\n<\/ol>\n<h4>&#25928;&#26524;&#35828;&#26126;&#65306;<\/h4>\n<p>Bootstrap&#26159;&#19968;&#31181;&#27969;&#34892;&#30340;&#21069;&#31471;&#26694;&#26550;&#65292;&#23427;&#30340;&#26629;&#26684;&#31995;&#32479;&#21487;&#20197;&#24110;&#21161;&#24320;&#21457;&#32773;&#24555;&#36895;&#21019;&#24314;&#21709;&#24212;&#24335;&#32593;&#39029;&#12290;&#36890;&#36807;&#20351;&#29992;Bootstrap&#26629;&#26684;&#31995;&#32479;&#65292;&#24744;&#21487;&#20197;&#26356;&#28789;&#27963;&#22320;&#25511;&#21046;&#21306;&#22359;&#30340;&#23485;&#24230;&#21644;&#38388;&#36317;&#65292;&#20174;&#32780;&#33719;&#24471;&#26356;&#22909;&#30340;&#29992;&#25143;&#20307;&#39564;&#12290;&#36825;&#31181;&#20570;&#27861;&#23588;&#20854;&#36866;&#21512;&#22823;&#22411;&#32593;&#31449;&#65292;&#22240;&#20026;&#23427;&#21487;&#20197;&#33258;&#21160;&#20248;&#21270;&#24067;&#23616;&#65292;&#20943;&#23569;&#32500;&#25252;&#24037;&#20316;&#37327;&#12290;<\/p>\n<p>&#27599;&#19968;&#31181;&#26041;&#27861;&#37117;&#26377;&#20854;&#36866;&#29992;&#22330;&#26223;&#21644;&#20248;&#21183;&#65292;&#26681;&#25454;&#20855;&#20307;&#38656;&#27714;&#36873;&#25321;&#26368;&#21512;&#36866;&#30340;&#26041;&#27861;&#12290;&#24076;&#26395;&#36825;&#20123;&#20449;&#24687;&#33021;&#24110;&#21161;&#24744;&#26356;&#22909;&#22320;&#29702;&#35299;&#21644;&#24212;&#29992;&#22312;WordPress&#21306;&#22359;&#20043;&#38388;&#30340;&#38388;&#36317;&#35843;&#25972;&#25216;&#24039;&#65281;<\/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;&#20320;&#21487;&#20197;&#36890;&#36807;&#22810;&#31181;&#26041;&#24335;&#22312;&#21306;&#22359;&#20043;&#38388;&#28155;&#21152;&#21644;&#21024;&#38500;&#31354;&#30333;&#21306;&#22495;&#12290;&#20197;&#19979;&#26159;&#22235;&#31181;&#19981;&#21516;&#30340;&#26041;&#27861;&#65306;<\/p>\n<ol>\n<li>&#20351;&#29992;<code>wp_insert_post_meta()<\/code>&#20989;&#25968;<\/li>\n<li>&#20351;&#29992;&#33258;&#23450;&#20041;&#20027;&#39064;&#21151;&#33021;<\/li>\n<li>&#20351;&#29992;&#33258;&#23450;&#20041;&#25554;&#20214;<\/li>\n<li>&#20351;&#29992;WordPress&#26412;&#36523;&#30340;&#21151;&#33021;<\/li>\n<\/ol>\n<h3>&#26041;&#27861;&#19968;&#65306;&#20351;&#29992;<code>wp_insert_post_meta()<\/code><\/h3>\n<h4>&#31034;&#20363;&#20195;&#30721;&#65306;<\/h4>\n<pre><code class=\"language-php\">add_filter( 'block_editor_insertions', function ( $insertions, $post_id ) {\n    \/\/ &#20551;&#35774;&#25105;&#20204;&#26377;&#19968;&#20010;&#21517;&#20026;\"content_block\"&#30340;&#22359;&#65292;&#38656;&#35201;&#25554;&#20837;&#21040;&#21478;&#19968;&#20010;&#21517;&#20026;\"sidebar_block\"&#30340;&#22359;&#20013;\n    if ( $post_id == 100 &amp;&amp; in_array('content_block', $insertions) ) {\n        $new_block = array(\n            'type' =&gt; 'text',\n            'value' =&gt; '&#36825;&#26159;&#19968;&#20010;&#26032;&#25554;&#20837;&#30340;&#20869;&#23481;',\n            'class' =&gt; 'content-block'\n        );\n        $insertions[] = $new_block;\n    }\n    return $insertions;\n}, 999 );\n\n\/\/ &#28155;&#21152;&#19968;&#20010;&#26032;&#22359;\n$sidebar_block = wp_create_block( 'sidebar_block', array(\n    'name' =&gt; '&#20391;&#36793;&#26639;',\n    'title' =&gt; '&#20391;&#36793;&#26639;&#26631;&#39064;',\n));\n$sidebar_block-&gt;set_attributes(array(\n    'class' =&gt; 'side-bar-content',\n));\n\n\/\/ &#25554;&#20837;&#26032;&#30340;&#22359;&#21040;&#24403;&#21069;&#39029;&#38754;\n$editor = wp_editor('', '', array('textarea_name' =&gt; 'my-textarea'));\necho $editor;\n\n\/\/ &#26174;&#31034;&#26032;&#30340;&#20391;&#36793;&#26639;\n?&gt;\n&lt;div class=\"side-bar\"&gt;\n    &lt;?php echo do_shortcode('[content_block]' . $sidebar_block-&gt;get_html()); ?&gt;\n&lt;\/div&gt;<\/code><\/pre>\n<h3>&#26041;&#27861;&#20108;&#65306;&#20351;&#29992;&#33258;&#23450;&#20041;&#20027;&#39064;&#21151;&#33021;<\/h3>\n<h4>&#31034;&#20363;&#20195;&#30721;&#65306;<\/h4>\n<pre><code class=\"language-php\">function my_theme_custom_function() {\n    add_action( 'blocks_inserted', function ($blocks) {\n        foreach ($blocks as $block) {\n            if (isset($block['type']) &amp;&amp; $block['type'] === 'header') {\n                $header = new WP_Block_Header($block);\n                $header-&gt;set_position($block['position']);\n                $header-&gt;render();\n            } elseif (isset($block['type']) &amp;&amp; $block['type'] === 'footer') {\n                $footer = new WP_Block_Footer($block);\n                $footer-&gt;set_position($block['position']);\n                $footer-&gt;render();\n            }\n        }\n    });\n}\n\nadd_action( 'init', 'my_theme_custom_function');<\/code><\/pre>\n<h3>&#26041;&#27861;&#19977;&#65306;&#20351;&#29992;&#33258;&#23450;&#20041;&#25554;&#20214;<\/h3>\n<h4>&#31034;&#20363;&#20195;&#30721;&#65306;<\/h4>\n<pre><code class=\"language-php\">require_once __DIR__ . '\/path\/to\/my-plugin\/class-my-plugin.php';\n\nif (!class_exists('MyPlugin')) {\n    require_once __DIR__ . '\/path\/to\/my-plugin\/plugin.php';\n}<\/code><\/pre>\n<h3>&#26041;&#27861;&#22235;&#65306;&#21033;&#29992;WordPress&#26412;&#36523;&#30340;&#21151;&#33021;<\/h3>\n<h4>&#31034;&#20363;&#20195;&#30721;&#65306;<\/h4>\n<pre><code class=\"language-php\">add_action( 'blocks_inserted', function ($blocks) {\n    foreach ($blocks as $block) {\n        if (isset($block['type']) &amp;&amp; $block['type'] === 'image') {\n            $img = new WP_Block_Image($block);\n            $img-&gt;set_image_url($block['attributes']['url']);\n            $img-&gt;render();\n        }\n    }\n});<\/code><\/pre>\n<p>&#36825;&#20123;&#26041;&#27861;&#36866;&#29992;&#20110;&#19981;&#21516;&#38656;&#27714;&#21644;&#22330;&#26223;&#12290;&#22312;&#23454;&#38469;&#25805;&#20316;&#26102;&#65292;&#35831;&#30830;&#20445;&#36981;&#24490;WordPress&#30340;&#20027;&#39064;&#25351;&#21335;&#21644;&#26368;&#20339;&#23454;&#36341;&#65292;&#20197;&#36991;&#20813;&#28508;&#22312;&#30340;&#23433;&#20840;&#38382;&#39064;&#21644;&#24615;&#33021;&#38382;&#39064;&#12290;<\/p>\r\n<\/div>\r\n<\/div>\r\n<\/div>\r\n<\/div>\n","protected":false},"excerpt":{"rendered":"<p>Bug&#32534;&#35793;&#29422; &#22312;WordPress&#20013;&#65292;&#21306;&#22359;&#20043;&#38388;&#30340;&#38388;&#36317;&#21487;&#20197;&#36890;&#36807;&#22810;&#038;#3..<\/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-2369","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\/2369","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=2369"}],"version-history":[{"count":0,"href":"https:\/\/www.zhaozhao123.cn\/wpcms\/wp-json\/wp\/v2\/posts\/2369\/revisions"}],"wp:attachment":[{"href":"https:\/\/www.zhaozhao123.cn\/wpcms\/wp-json\/wp\/v2\/media?parent=2369"}],"wp:term":[{"taxonomy":"category","embeddable":true,"href":"https:\/\/www.zhaozhao123.cn\/wpcms\/wp-json\/wp\/v2\/categories?post=2369"},{"taxonomy":"post_tag","embeddable":true,"href":"https:\/\/www.zhaozhao123.cn\/wpcms\/wp-json\/wp\/v2\/tags?post=2369"},{"taxonomy":"tuisongtax","embeddable":true,"href":"https:\/\/www.zhaozhao123.cn\/wpcms\/wp-json\/wp\/v2\/tuisongtax?post=2369"}],"curies":[{"name":"wp","href":"https:\/\/api.w.org\/{rel}","templated":true}]}}