{"id":1859,"date":"2025-06-10T16:59:12","date_gmt":"2025-06-10T08:59:12","guid":{"rendered":"https:\/\/www.zhaozhao123.cn\/wpcms\/wpdt\/1859.html"},"modified":"2025-06-10T16:59:12","modified_gmt":"2025-06-10T08:59:12","slug":"%e5%a6%82%e4%bd%95%e5%9c%a8%e4%be%a7%e8%be%b9%e6%a0%8f%e4%b8%ad%e8%87%aa%e5%ae%9a%e4%b9%89wordpress%e6%a1%a3%e6%a1%88%e7%9a%84%e6%98%be%e7%a4%ba","status":"publish","type":"post","link":"https:\/\/www.zhaozhao123.cn\/wpcms\/post\/1859.html","title":{"rendered":"\u5982\u4f55\u5728\u4fa7\u8fb9\u680f\u4e2d\u81ea\u5b9a\u4e49WordPress\u6863\u6848\u7684\u663e\u793a"},"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;&#23454;&#29616;&#20391;&#36793;&#26639;&#20013;&#30340;&#33258;&#23450;&#20041;WordPress&#26723;&#26696;&#26174;&#31034;&#65292;&#25105;&#20204;&#21487;&#20197;&#36890;&#36807;&#20462;&#25913;&#27169;&#26495;&#25991;&#20214;&#26469;&#25511;&#21046;&#29305;&#23450;&#31867;&#21035;&#25110;&#26631;&#31614;&#30340;&#25991;&#31456;&#23637;&#31034;&#26041;&#24335;&#12290;&#36825;&#37324;&#25105;&#23558;&#25552;&#20379;&#19968;&#20010;&#31616;&#21333;&#30340;&#31034;&#20363;&#65292;&#23637;&#31034;&#22914;&#20309;&#22312;&#20391;&#36793;&#26639;&#20013;&#20165;&#26174;&#31034;&#26576;&#20010;&#20998;&#31867;&#19979;&#30340;&#25991;&#31456;&#12290;<\/p>\n<h3>&#27493;&#39588; 1: &#20462;&#25913;&#20027;&#39064;&#30340;&#20027;&#27169;&#26495;<\/h3>\n<p>&#39318;&#20808;&#65292;&#25105;&#20204;&#38656;&#35201;&#25214;&#21040;&#24182;&#20462;&#25913;&#20027;&#39064;&#30340;&#20027;&#27169;&#26495;&#25991;&#20214;&#65288;&#36890;&#24120;&#26159; <code>archive.php<\/code>&#65289;&#12290;&#36825;&#20010;&#25991;&#20214;&#36127;&#36131;&#22788;&#29702;&#25152;&#26377;&#31867;&#22411;&#30340;&#24402;&#26723;&#39029;&#38754;&#65292;&#21253;&#25324;&#21333;&#20010;&#20998;&#31867;&#21644;&#26631;&#31614;&#12290;<\/p>\n<pre><code class=\"language-php\">\/\/ &#25171;&#24320;&#20027;&#39064;&#30340;&#20027;&#27169;&#26495;&#25991;&#20214;\nrequire get_template_directory() . '\/inc\/archive-template.php';<\/code><\/pre>\n<h3>&#27493;&#39588; 2: &#21019;&#24314;&#33258;&#23450;&#20041;&#30340;archive-template.php &#25991;&#20214;<\/h3>\n<p>&#25509;&#19979;&#26469;&#65292;&#22312;&#20320;&#30340;&#20027;&#39064;&#30446;&#24405;&#19979;&#21019;&#24314;&#19968;&#20010;&#26032;&#30340;PHP&#25991;&#20214;&#65292;&#20363;&#22914; <code>archive-template.php<\/code>&#65292;&#24182;&#22312;&#20854;&#20013;&#28155;&#21152;&#20197;&#19979;&#20195;&#30721;&#65306;<\/p>\n<pre><code class=\"language-php\">&lt;?php if ( have_posts() ) : ?&gt;\n    &lt;?php while ( have_posts() ) : the_post(); ?&gt;\n        &lt;article id=\"post-&lt;?php the_ID(); ?&gt;\" &lt;?php post_class(); ?&gt;&gt;\n            &lt;!-- &#21407;&#22987;&#25991;&#31456;&#20869;&#23481; --&gt;\n        &lt;\/article&gt;\n    &lt;?php endwhile; ?&gt;\n&lt;?php else : ?&gt;\n    &lt;p&gt;&lt;?php _e( 'Sorry, no posts matched your criteria.' ); ?&gt;&lt;\/p&gt;\n&lt;?php endif; ?&gt;<\/code><\/pre>\n<h3>&#27493;&#39588; 3: &#28155;&#21152;&#20998;&#31867;&#31579;&#36873;&#21151;&#33021;<\/h3>\n<p>&#20026;&#20102;&#20351;&#29992;&#25143;&#33021;&#22815;&#36873;&#25321;&#29305;&#23450;&#20998;&#31867;&#65292;&#20320;&#38656;&#35201;&#22312; <code>archive.php<\/code> &#25110; <code>archive-template.php<\/code> &#20013;&#28155;&#21152;&#19968;&#20010;&#25628;&#32034;&#26694;&#65292;&#20801;&#35768;&#29992;&#25143;&#36755;&#20837;&#20998;&#31867;&#21517;&#31216;&#20197;&#31579;&#36873;&#25991;&#31456;&#12290;<\/p>\n<h4>&#22312; <code>archive.php<\/code> &#20013;&#28155;&#21152;&#25628;&#32034;&#26694;&#65306;<\/h4>\n<pre><code class=\"language-php\">&lt;div class=\"search-form\"&gt;\n    &lt;form action=\"&lt;?php echo home_url( '\/' ); ?&gt;\" method=\"get\"&gt;\n        &lt;input type=\"text\" name=\"s\" placeholder=\"Search by category...\"&gt;\n        &lt;button type=\"submit\"&gt;Search&lt;\/button&gt;\n    &lt;\/form&gt;\n&lt;\/div&gt;\n\n&lt;!-- &#25628;&#32034;&#32467;&#26524; --&gt;\n&lt;?php query_posts(array('cat' =&gt; $selected_category)); ?&gt;\n\n&lt;?php if (have_posts()) : while (have_posts()) : the_post(); ?&gt;\n    &lt;article id=\"post-&lt;?php the_ID(); ?&gt;\" &lt;?php post_class(); ?&gt;&gt;\n        &lt;!-- &#25991;&#31456;&#20869;&#23481; --&gt;\n    &lt;\/article&gt;\n&lt;?php endwhile; ?&gt;\n&lt;?php endif; ?&gt;<\/code><\/pre>\n<p>&#22312;&#36825;&#20010;&#20363;&#23376;&#20013;&#65292;&#20551;&#35774; <code>$selected_category<\/code> &#26159;&#20174;&#25628;&#32034;&#26694;&#33719;&#21462;&#21040;&#30340;&#20998;&#31867;ID&#12290;<\/p>\n<h3>&#27493;&#39588; 4: &#23558;&#20195;&#30721;&#38598;&#25104;&#21040;&#20027;&#39064;&#20013;<\/h3>\n<p>&#30830;&#20445;&#20320;&#30340;&#20027;&#39064;&#25903;&#25345; <code>query_posts()<\/code> &#20989;&#25968;&#65292;&#22240;&#20026;&#36825;&#26159;&#36890;&#36807;&#20462;&#25913;&#20027;&#27169;&#26495;&#26469;&#24433;&#21709;&#25991;&#31456;&#26174;&#31034;&#30340;&#26041;&#24335;&#12290;<\/p>\n<h3>&#27493;&#39588; 5: &#27979;&#35797;&#24744;&#30340;&#26356;&#25913;<\/h3>\n<p>&#20445;&#23384;&#25152;&#26377;&#26356;&#25913;&#21518;&#65292;&#26356;&#26032; WordPress &#30340;&#32531;&#23384;&#65292;&#28982;&#21518;&#35775;&#38382;&#24744;&#24076;&#26395;&#27979;&#35797;&#30340;&#26032;&#20027;&#39029;&#25110;&#20219;&#20309;&#20854;&#20182;&#20855;&#26377;&#20391;&#36793;&#26639;&#30340;&#25991;&#31456;&#21015;&#34920;&#39029;&#38754;&#12290;&#20320;&#24212;&#35813;&#33021;&#30475;&#21040;&#26681;&#25454;&#24744;&#35774;&#32622;&#30340;&#26465;&#20214;&#21482;&#26174;&#31034;&#25351;&#23450;&#20998;&#31867;&#30340;&#25991;&#31456;&#12290;<\/p>\n<h3>&#24635;&#32467;<\/h3>\n<p>&#36890;&#36807;&#19978;&#36848;&#27493;&#39588;&#65292;&#20320;&#21487;&#20197;&#25104;&#21151;&#22320;&#22312;&#20391;&#36793;&#26639;&#20013;&#23450;&#21046;&#26174;&#31034;WordPress&#25991;&#31456;&#65292;&#29305;&#21035;&#26159;&#24403;&#20320;&#21482;&#24819;&#26174;&#31034;&#29305;&#23450;&#20998;&#31867;&#19979;&#30340;&#25991;&#31456;&#26102;&#12290;&#36825;&#31181;&#26041;&#27861;&#20381;&#36182;&#20110; <code>query_posts()<\/code> &#20989;&#25968;&#65292;&#23427;&#20801;&#35768;&#20320;&#22312;&#19981;&#25913;&#21464;&#26680;&#24515;WordPress&#32467;&#26500;&#30340;&#24773;&#20917;&#19979;&#20462;&#25913;&#25991;&#31456;&#26597;&#35810;&#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;&#20320;&#21487;&#20197;&#20351;&#29992;&#22810;&#31181;&#26041;&#24335;&#26469;&#23450;&#21046;&#20391;&#36793;&#26639;&#30340;&#20869;&#23481;&#12290;&#20197;&#19979;&#26159;&#19968;&#20123;&#24120;&#35265;&#30340;&#26041;&#27861;&#65306;<\/p>\n<h3>1. &#20351;&#29992;<code>sidebars_widgets_init()<\/code>&#20989;&#25968;<\/h3>\n<p><strong>&#21407;&#29702;<\/strong>: <code>sidebars_widgets_init()<\/code>&#20989;&#25968;&#29992;&#20110;&#21021;&#22987;&#21270;&#20391;&#36793;&#26639;&#25554;&#20214;&#12290;<\/p>\n<pre><code class=\"language-php\">function my_custom_sidebars() {\n    register_sidebar(array(\n        'name' =&gt; 'Sidebar A',\n        'id' =&gt; 'sidebar-a',\n        'before_widget' =&gt; '&lt;div id=\"%1$s\" class=\"widget %2$s\"&gt;',\n        'after_widget' =&gt; '&lt;\/div&gt;',\n        'before_title' =&gt; '&lt;h3&gt;',\n        'after_title' =&gt; '&lt;\/h3&gt;'\n    ));\n}\nadd_action('widgets_init', 'my_custom_sidebars');<\/code><\/pre>\n<p><strong>&#31034;&#20363;&#20195;&#30721;<\/strong>:<\/p>\n<pre><code class=\"language-html\">&lt;div class=\"widget\"&gt;\n    &lt;h3&gt;Header&lt;\/h3&gt;\n    &lt;!-- &#22312;&#36825;&#37324;&#28155;&#21152;&#20391;&#36793;&#26639;&#30340;&#20869;&#23481; --&gt;\n&lt;\/div&gt;\n\n&lt;!-- &#36825;&#37324;&#21487;&#20197;&#25554;&#20837;&#26356;&#22810;&#20391;&#36793;&#26639;&#30340;&#20869;&#23481; --&gt;<\/code><\/pre>\n<h3>2. &#20351;&#29992;&#33258;&#23450;&#20041;&#27169;&#26495;&#25991;&#20214;<\/h3>\n<p><strong>&#21407;&#29702;<\/strong>: WordPress&#25552;&#20379;&#20102;&#19968;&#20010;&#21517;&#20026;<code>wp-admin\/admin.php<\/code>&#30340;&#40664;&#35748;&#27169;&#26495;&#25991;&#20214;&#65292;&#20320;&#21487;&#20197;&#22312;&#27492;&#25991;&#20214;&#20013;&#32534;&#20889;&#33258;&#23450;&#20041;&#30340;&#20027;&#39064;&#21151;&#33021;&#12290;<\/p>\n<pre><code class=\"language-php\">\/\/ &#33258;&#23450;&#20041;&#27169;&#26495;&#25991;&#20214;\nfunction my_theme_setup() {\n    \/\/ &#35774;&#32622;&#20027;&#39064;&#36873;&#39033;\n    $theme_options = array(\n        'custom_option_name' =&gt; 'your_value'\n    );\n\n    \/\/ &#27880;&#20876;&#20027;&#39064;&#36873;&#39033;\n    add_theme_support('custom-options', $theme_options);\n}\n\nadd_action('after_setup_theme', 'my_theme_setup');<\/code><\/pre>\n<p><strong>&#31034;&#20363;&#20195;&#30721;<\/strong>:<\/p>\n<pre><code class=\"language-php\">&lt;div class=\"header\"&gt;\n    &lt;h1&gt;My Custom Header&lt;\/h1&gt;\n    &lt;!-- &#22312;&#36825;&#37324;&#28155;&#21152;&#20391;&#36793;&#26639;&#30340;&#20869;&#23481; --&gt;\n&lt;\/div&gt;\n\n&lt;!-- &#36825;&#37324;&#21487;&#20197;&#25554;&#20837;&#26356;&#22810;&#20391;&#36793;&#26639;&#30340;&#20869;&#23481; --&gt;<\/code><\/pre>\n<h3>3. &#20351;&#29992;&#33258;&#23450;&#20041;&#25554;&#20214;<\/h3>\n<p><strong>&#21407;&#29702;<\/strong>: WordPress&#20801;&#35768;&#24320;&#21457;&#20154;&#21592;&#21019;&#24314;&#33258;&#23450;&#20041;&#25554;&#20214;&#24182;&#23558;&#20854;&#38598;&#25104;&#21040;WordPress&#20013;&#12290;<\/p>\n<ul>\n<li>&#21019;&#24314;&#19968;&#20010;&#26032;&#25554;&#20214;&#65288;&#22914;<code>custom_sidebars.php<\/code>)<\/li>\n<li>&#32534;&#36753;&#35813;&#25554;&#20214;&#65292;&#28155;&#21152;&#33258;&#23450;&#20041;&#30340;&#21151;&#33021;&#21644;&#30028;&#38754;<\/li>\n<\/ul>\n<p><strong>&#31034;&#20363;&#20195;&#30721;<\/strong>:<\/p>\n<pre><code class=\"language-php\">function custom_sidebars() {\n    return array(\n        'sidebar_a' =&gt; array(\n            'id' =&gt; 'sidebar_a',\n            'title' =&gt; 'Sidebar A',\n            'description' =&gt; 'This is the description of Sidebar A.',\n            'content' =&gt; '&lt;div class=\"widget\"&gt;...&lt;\/div&gt;',\n        ),\n    );\n}\n\nregister_sidebar(custom_sidebars());<\/code><\/pre>\n<p>&#36890;&#36807;&#36825;&#20123;&#26041;&#27861;&#65292;&#20320;&#21487;&#20197;&#26681;&#25454;&#38656;&#35201;&#33258;&#23450;&#20041;WordPress&#20391;&#36793;&#26639;&#30340;&#20869;&#23481;&#12290;&#20363;&#22914;&#65292;&#20320;&#21487;&#20197;&#28155;&#21152;&#29305;&#23450;&#30340;&#39029;&#38754;&#25110;&#26631;&#31614;&#20026;&#20391;&#36793;&#26639;&#65292;&#25110;&#32773;&#22312;&#20391;&#36793;&#26639;&#20013;&#25918;&#32622;&#33258;&#23450;&#20041;&#30340;HTML&#20803;&#32032;&#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;&#23454;&#29616;&#20391;&#36793;&#26639;&#20013;&#30340;&#33258;&#23450;&#20041;WordPress&#26723;&#26696;&#26174;&#31034;&#038;#6..<\/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":[52,53],"tuisongtax":[],"class_list":["post-1859","post","type-post","status-publish","format-standard","hentry","category-wpdt","tag-ztjc","tag-ztmbpzjc"],"acf":[],"_links":{"self":[{"href":"https:\/\/www.zhaozhao123.cn\/wpcms\/wp-json\/wp\/v2\/posts\/1859","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=1859"}],"version-history":[{"count":0,"href":"https:\/\/www.zhaozhao123.cn\/wpcms\/wp-json\/wp\/v2\/posts\/1859\/revisions"}],"wp:attachment":[{"href":"https:\/\/www.zhaozhao123.cn\/wpcms\/wp-json\/wp\/v2\/media?parent=1859"}],"wp:term":[{"taxonomy":"category","embeddable":true,"href":"https:\/\/www.zhaozhao123.cn\/wpcms\/wp-json\/wp\/v2\/categories?post=1859"},{"taxonomy":"post_tag","embeddable":true,"href":"https:\/\/www.zhaozhao123.cn\/wpcms\/wp-json\/wp\/v2\/tags?post=1859"},{"taxonomy":"tuisongtax","embeddable":true,"href":"https:\/\/www.zhaozhao123.cn\/wpcms\/wp-json\/wp\/v2\/tuisongtax?post=1859"}],"curies":[{"name":"wp","href":"https:\/\/api.w.org\/{rel}","templated":true}]}}