{"id":1950,"date":"2025-06-10T18:12:43","date_gmt":"2025-06-10T10:12:43","guid":{"rendered":"https:\/\/www.zhaozhao123.cn\/wpcms\/wpdt\/1950.html"},"modified":"2025-06-14T11:42:18","modified_gmt":"2025-06-14T03:42:18","slug":"%e5%a6%82%e4%bd%95%e5%9c%a8%e6%82%a8%e7%9a%84wordpress%e4%b8%bb%e9%a2%98%e4%b8%ad%e6%98%be%e7%a4%ba%e5%8d%9a%e5%ae%a2%e6%96%87%e7%ab%a0%e5%85%83%e6%95%b0%e6%8d%ae","status":"publish","type":"post","link":"https:\/\/www.zhaozhao123.cn\/wpcms\/post\/1950.html","title":{"rendered":"\u5982\u4f55\u5728\u60a8\u7684WordPress\u4e3b\u9898\u4e2d\u663e\u793a\u535a\u5ba2\u6587\u7ae0\u5143\u6570\u636e"},"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&#20027;&#39064;&#20013;&#26174;&#31034;&#21338;&#23458;&#25991;&#31456;&#30340;&#20803;&#25968;&#25454;&#65288;&#22914;&#26631;&#39064;&#12289;&#20316;&#32773;&#12289;&#21457;&#24067;&#26102;&#38388;&#31561;&#65289;&#65292;&#24744;&#21487;&#20197;&#36890;&#36807;&#20197;&#19979;&#27493;&#39588;&#23454;&#29616;&#65306;<\/p>\n<h3>&#27493;&#39588; 1: &#25214;&#21040;&#20027;&#39064;&#25991;&#20214;<\/h3>\n<p>&#39318;&#20808;&#65292;&#30830;&#23450;&#24744;&#35201;&#20462;&#25913;&#30340;&#20027;&#39064;&#25991;&#20214;&#20301;&#32622;&#12290;&#22823;&#22810;&#25968;&#20027;&#39064;&#25991;&#20214;&#36890;&#24120;&#20301;&#20110; <code>wp-content\/themes\/<\/code> &#30446;&#24405;&#19979;&#12290;<\/p>\n<h3>&#27493;&#39588; 2: &#28155;&#21152;&#27169;&#26495;&#25991;&#20214;<\/h3>\n<p>&#25509;&#19979;&#26469;&#65292;&#22312;&#20027;&#39064;&#25991;&#20214;&#22841;&#20013;&#25214;&#21040;&#19982;&#39029;&#38754;&#25110;&#24086;&#23376;&#30456;&#20851;&#30340;&#27169;&#26495;&#25991;&#20214;&#12290;&#20363;&#22914;&#65292;&#22914;&#26524;&#24744;&#24819;&#28155;&#21152;&#21040;&#25152;&#26377;&#39029;&#38754;&#21644;&#24086;&#23376;&#20013;&#65292;&#21487;&#20197;&#26597;&#30475; <code>single.php<\/code> &#25991;&#20214;&#65307;&#22914;&#26524;&#21482;&#24819;&#22312;&#29305;&#23450;&#39029;&#38754;&#19978;&#26174;&#31034;&#65292;&#21017;&#21487;&#33021;&#38656;&#35201;&#26597;&#30475; <code>page.php<\/code> &#25110;&#20854;&#20182;&#30456;&#20851;&#25991;&#20214;&#12290;<\/p>\n<h3>&#27493;&#39588; 3: &#25554;&#20837;HTML&#20195;&#30721;<\/h3>\n<p>&#22312;&#27169;&#26495;&#25991;&#20214;&#20013;&#25554;&#20837;&#36866;&#24403;&#30340;HTML&#20195;&#30721;&#26469;&#26174;&#31034;&#20803;&#25968;&#25454;&#12290;&#24744;&#21487;&#20197;&#20351;&#29992;PHP&#20195;&#30721;&#21160;&#24577;&#29983;&#25104;&#36825;&#20123;&#20449;&#24687;&#12290;<\/p>\n<h4>&#31034;&#20363;&#20195;&#30721;&#65306;<\/h4>\n<pre><code class=\"language-php\">&lt;?php\n\/\/ &#33719;&#21462;&#24403;&#21069;&#25991;&#31456;&#30340;&#20803;&#25968;&#25454;\n$author = get_the_author();\n$date = get_the_date('F j, Y');\n$title = get_the_title();\n\n\/\/ &#36755;&#20986;&#20803;&#25968;&#25454;\necho '&lt;h2&gt;&lt;a href=\"' . esc_url(get_permalink()) . '\"&gt;' . $title . '&lt;\/a&gt;&lt;\/h2&gt;';\necho '&lt;small&gt;' . sprintf('&lt;strong&gt;%s&lt;\/strong&gt;: %s', 'Author:', $author) . '&lt;\/small&gt;';\necho '&lt;small&gt;' . sprintf('&lt;strong&gt;Date:&lt;\/strong&gt;, %s', $date) . '&lt;\/small&gt;';\n?&gt;<\/code><\/pre>\n<h3>&#27493;&#39588; 4: &#26356;&#26032;&#20027;&#39064;&#25991;&#20214;<\/h3>\n<p>&#20445;&#23384;&#23545;&#27169;&#26495;&#25991;&#20214;&#30340;&#26356;&#25913;&#21518;&#65292;&#30830;&#20445;&#26356;&#26032;&#20027;&#39064;&#25991;&#20214;&#20197;&#24212;&#29992;&#36825;&#20123;&#21464;&#21270;&#12290;<\/p>\n<h3>&#27493;&#39588; 5: &#27979;&#35797;&#25928;&#26524;<\/h3>\n<p>&#21047;&#26032;&#27983;&#35272;&#22120;&#65292;&#26816;&#26597;&#26159;&#21542;&#27491;&#30830;&#26174;&#31034;&#20102;&#21338;&#23458;&#25991;&#31456;&#30340;&#20803;&#25968;&#25454;&#12290;<\/p>\n<p>&#36890;&#36807;&#19978;&#36848;&#27493;&#39588;&#65292;&#24744;&#21487;&#20197;&#22312;WordPress&#20027;&#39064;&#20013;&#25104;&#21151;&#23637;&#31034;&#21338;&#23458;&#25991;&#31456;&#30340;&#20803;&#25968;&#25454;&#12290;&#27492;&#26041;&#27861;&#36866;&#29992;&#20110;&#22823;&#22810;&#25968;&#24773;&#20917;&#65292;&#20294;&#20855;&#20307;&#23454;&#29616;&#21487;&#33021;&#20250;&#26681;&#25454;&#24744;&#30340;&#20027;&#39064;&#32467;&#26500;&#26377;&#25152;&#19981;&#21516;&#12290;&#24076;&#26395;&#36825;&#33021;&#24110;&#21161;&#24744;&#26356;&#22909;&#22320;&#29702;&#35299;&#21644;&#23454;&#26045;&#36825;&#19968;&#21151;&#33021;&#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&#20027;&#39064;&#20013;&#26174;&#31034;&#21338;&#23458;&#25991;&#31456;&#20803;&#25968;&#25454;&#26159;&#19968;&#31181;&#24120;&#35265;&#30340;&#38656;&#27714;&#65292;&#23427;&#21487;&#20197;&#24110;&#21161;&#29992;&#25143;&#26356;&#26041;&#20415;&#22320;&#20102;&#35299;&#21644;&#27983;&#35272;&#32593;&#31449;&#30340;&#20869;&#23481;&#12290;&#20197;&#19979;&#26159;&#22914;&#20309;&#22312;WordPress&#20027;&#39064;&#20013;&#23454;&#29616;&#36825;&#19968;&#21151;&#33021;&#30340;&#26041;&#27861;&#65306;<\/p>\n<h3>1. &#35774;&#32622;Meta Box<\/h3>\n<p>&#39318;&#20808;&#65292;&#22312;&#24744;&#30340;WordPress&#20027;&#39064;&#20013;&#21019;&#24314;&#19968;&#20010;Meta Box&#65292;&#29992;&#20110;&#26174;&#31034;&#21338;&#23458;&#25991;&#31456;&#30340;&#20803;&#25968;&#25454;&#12290;Meta Box&#36890;&#24120;&#20301;&#20110;&#39030;&#37096;&#33756;&#21333;&#25110;&#24213;&#37096;&#26639;&#65292;&#21487;&#20197;&#29992;&#26469;&#28155;&#21152;&#33258;&#23450;&#20041;&#23383;&#27573;&#12290;<\/p>\n<h4>&#31034;&#20363;&#20195;&#30721;&#65306;<\/h4>\n<pre><code class=\"language-html\">&lt;div class=\"wrap\"&gt;\n    &lt;h2&gt;&lt;?php esc_html_e( 'Meta Boxes', 'your-theme' ); ?&gt;&lt;\/h2&gt;\n    &lt;?php if ( have_posts() ) : while ( have_posts() ) : the_post(); ?&gt;\n        &lt;form method=\"post\" action=\"&lt;?php echo esc_url( get_permalink() ); ?&gt;\"&gt;\n            &lt;?php wp_nonce_field( 'edit_theme_options', 'edit_theme_options_nonce' ); ?&gt;\n            &lt;label for=\"meta_box_title\"&gt;&lt;?php _e( 'Title', 'your-theme' ); ?&gt;:&lt;\/label&gt;\n            &lt;input type=\"text\" name=\"meta_box_title\" id=\"meta_box_title\" value=\"&lt;?php the_title_attribute(); ?&gt;\" \/&gt;\n            &lt;br\/&gt;\n            &lt;label for=\"meta_description\"&gt;&lt;?php _e( 'Description', 'your-theme' ); ?&gt;:&lt;\/label&gt;\n            &lt;textarea name=\"meta_description\" id=\"meta_description\"&gt;&lt;?php the_excerpt(); ?&gt;&lt;\/textarea&gt;&lt;br\/&gt;\n            &lt;button type=\"submit\"&gt;&lt;?php _e( 'Save Changes', 'your-theme' ); ?&gt;&lt;\/button&gt;\n        &lt;\/form&gt;\n    &lt;?php endwhile; endif; ?&gt;\n&lt;\/div&gt;<\/code><\/pre>\n<p><strong>&#27880;&#24847;&#65306;<\/strong><\/p>\n<ul>\n<li><code>&lt;?php echo esc_html(e()) ?&gt;<\/code> &#26159;&#20026;&#20102;&#30830;&#20445;&#36755;&#20986;&#20026;HTML&#26684;&#24335;&#12290;<\/li>\n<li><code>the_title()<\/code> &#21644; <code>the_excerpt()<\/code> &#21487;&#20197;&#26681;&#25454;&#38656;&#35201;&#26367;&#25442;&#20026;&#30456;&#24212;&#30340;&#20989;&#25968;&#26469;&#33719;&#21462;&#26631;&#39064;&#21644;&#25688;&#35201;&#12290;<\/li>\n<li>&#20351;&#29992; <code>wp_nonce_field('...')<\/code> &#29992;&#20110;&#23433;&#20840;&#39564;&#35777;&#25552;&#20132;&#34920;&#21333;&#12290;<\/li>\n<\/ul>\n<h3>2. &#32534;&#36753; Meta Box &#37197;&#32622;<\/h3>\n<p>&#19968;&#26086;&#35774;&#32622;&#20102;Meta Box&#65292;&#24744;&#36824;&#38656;&#35201;&#32534;&#36753;&#20854;&#37197;&#32622;&#20197;&#20415;&#20110;&#35775;&#38382;&#12290;<\/p>\n<h4>&#31034;&#20363;&#20195;&#30721;&#65306;<\/h4>\n<pre><code class=\"language-xml\">&lt;page&gt;\n    &lt;name&gt;&lt;?php esc_attr_e( 'Your WordPress Theme Name', 'your-theme' ); ?&gt;&lt;\/name&gt;\n    &lt;template.php&gt;\n        &lt;head&gt;\n            &lt;!-- Your theme's CSS --&gt;\n        &lt;\/head&gt;\n        &lt;body&gt;\n            &lt;meta-box&gt;\n                &lt;title&gt;&lt;?php esc_html_e( 'Title', 'your-theme' ); ?&gt;&lt;\/title&gt;\n                &lt;description&gt;&lt;?php esc_html_e( 'Description', 'your-theme' ); ?&gt;&lt;\/description&gt;\n            &lt;\/meta-box&gt;\n        &lt;\/body&gt;\n    &lt;\/template.php&gt;\n&lt;\/page&gt;<\/code><\/pre>\n<p><strong>&#27880;&#24847;&#65306;<\/strong><\/p>\n<ul>\n<li><code>&lt;?php esc_html_e( 'Your WordPress Theme Name', 'your-theme' ); ?&gt;<\/code> &#24212;&#29992;&#21040; <code>&lt;name&gt;<\/code> &#26631;&#31614;&#20869;&#65292;&#20197;&#25351;&#23450;&#35813;&#39029;&#38754;&#30340;&#20027;&#39064;&#21517;&#31216;&#12290;<\/li>\n<\/ul>\n<p>&#36890;&#36807;&#19978;&#36848;&#26041;&#27861;&#65292;&#24744;&#21487;&#20197;&#25104;&#21151;&#35774;&#32622;&#24182;&#26174;&#31034;WordPress&#20027;&#39064;&#20013;&#30340;&#21338;&#23458;&#25991;&#31456;&#20803;&#25968;&#25454;&#12290;&#36825;&#31181;&#26041;&#27861;&#19981;&#20165;&#26377;&#21161;&#20110;&#20248;&#21270;&#29992;&#25143;&#20307;&#39564;&#65292;&#36824;&#25552;&#39640;&#20102;&#32593;&#31449;&#30340;&#19987;&#19994;&#24615;&#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&#20027;&#39064;&#20013;&#26174;&#31034;&#21338;&#23458;&#25991;&#31456;&#30340;&#20803;&#25968;&#25454;&#038;#6..<\/p>\n","protected":false},"author":1,"featured_media":0,"comment_status":"closed","ping_status":"","sticky":false,"template":"","format":"standard","meta":{"_acf_changed":false,"footnotes":""},"categories":[1],"tags":[3189,52,53],"tuisongtax":[],"class_list":["post-1950","post","type-post","status-publish","format-standard","hentry","category-wpdt","tag-zt","tag-ztjc","tag-ztmbpzjc"],"acf":[],"_links":{"self":[{"href":"https:\/\/www.zhaozhao123.cn\/wpcms\/wp-json\/wp\/v2\/posts\/1950","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=1950"}],"version-history":[{"count":0,"href":"https:\/\/www.zhaozhao123.cn\/wpcms\/wp-json\/wp\/v2\/posts\/1950\/revisions"}],"wp:attachment":[{"href":"https:\/\/www.zhaozhao123.cn\/wpcms\/wp-json\/wp\/v2\/media?parent=1950"}],"wp:term":[{"taxonomy":"category","embeddable":true,"href":"https:\/\/www.zhaozhao123.cn\/wpcms\/wp-json\/wp\/v2\/categories?post=1950"},{"taxonomy":"post_tag","embeddable":true,"href":"https:\/\/www.zhaozhao123.cn\/wpcms\/wp-json\/wp\/v2\/tags?post=1950"},{"taxonomy":"tuisongtax","embeddable":true,"href":"https:\/\/www.zhaozhao123.cn\/wpcms\/wp-json\/wp\/v2\/tuisongtax?post=1950"}],"curies":[{"name":"wp","href":"https:\/\/api.w.org\/{rel}","templated":true}]}}