{"id":2332,"date":"2025-06-11T00:56:09","date_gmt":"2025-06-10T16:56:09","guid":{"rendered":"https:\/\/www.zhaozhao123.cn\/wpcms\/wpdt\/2332.html"},"modified":"2025-06-11T00:56:09","modified_gmt":"2025-06-10T16:56:09","slug":"%e5%a6%82%e4%bd%95%e5%9c%a8-wordpress-%e4%b8%ad%e8%ae%be%e7%bd%ae%e8%87%aa%e5%8a%a8%e6%bb%b4%e7%81%8c%e9%80%9a%e7%9f%a5","status":"publish","type":"post","link":"https:\/\/www.zhaozhao123.cn\/wpcms\/post\/2332.html","title":{"rendered":"\u5982\u4f55\u5728 WordPress \u4e2d\u8bbe\u7f6e\u81ea\u52a8\u6ef4\u704c\u901a\u77e5"},"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;&#35774;&#32622;&#33258;&#21160;&#28404;&#28748;&#36890;&#30693;&#65288;&#21363;&#33258;&#21160;&#21457;&#36865;&#37038;&#20214;&#25552;&#37266;&#65289;&#21487;&#20197;&#24110;&#21161;&#29992;&#25143;&#21450;&#26102;&#20102;&#35299;&#29305;&#23450;&#20107;&#20214;&#25110;&#27963;&#21160;&#30340;&#36890;&#30693;&#12290;&#36825;&#19981;&#20165;&#21487;&#20197;&#25552;&#39640;&#29992;&#25143;&#30340;&#21442;&#19982;&#24230;&#21644;&#28385;&#24847;&#24230;&#65292;&#36824;&#21487;&#20197;&#24110;&#21161;&#31649;&#29702;&#21592;&#26356;&#22909;&#22320;&#31649;&#29702;&#31038;&#21306;&#25110;&#32593;&#31449;&#30340;&#27963;&#21160;&#12290;&#20197;&#19979;&#26159;&#22914;&#20309;&#22312; WordPress &#20013;&#35774;&#32622;&#33258;&#21160;&#28404;&#28748;&#36890;&#30693;&#30340;&#27493;&#39588;&#65306;<\/p>\n<h3>&#27493;&#39588; 1: &#30331;&#24405;&#21040;&#24744;&#30340; WordPress &#31649;&#29702;&#38754;&#26495;<\/h3>\n<p>&#39318;&#20808;&#65292;&#30331;&#24405;&#21040;&#24744; WordPress &#20027;&#26426;&#19978;&#30340;&#25511;&#21046;&#38754;&#26495;&#12290;&#36890;&#24120;&#36825;&#20010;&#38754;&#26495;&#21487;&#20197;&#36890;&#36807;&#27983;&#35272;&#22120;&#35775;&#38382;&#65292;&#40664;&#35748;&#22320;&#22336;&#20026; <code>http:\/\/yourwebsite.com\/wp-admin<\/code>&#12290;<\/p>\n<h3>&#27493;&#39588; 2: &#23548;&#33322;&#21040;&ldquo;&#33258;&#23450;&#20041;&rdquo;&#36873;&#39033;&#21345;<\/h3>\n<p>&#22312;&#24038;&#20391;&#33756;&#21333;&#26639;&#20013;&#25214;&#21040;&#24182;&#28857;&#20987;&ldquo;&#33258;&#23450;&#20041;&rdquo;&#65292;&#28982;&#21518;&#36873;&#25321;&#30456;&#24212;&#30340;&#23376;&#33756;&#21333;&#65292;&#20363;&#22914;&ldquo;&#25554;&#20214;&rdquo;&#12290;<\/p>\n<h3>&#27493;&#39588; 3: &#25628;&#32034;&#24182;&#23433;&#35013;&#33258;&#21160;&#28404;&#28748;&#36890;&#30693;&#25554;&#20214;<\/h3>\n<p>&#22312;&#25628;&#32034;&#26694;&#20013;&#36755;&#20837;&ldquo;&#33258;&#21160;&#28404;&#28748;&#36890;&#30693;&rdquo;&#25110;&#32773;&#31867;&#20284;&#20851;&#38190;&#35789;&#65292;&#22914;&ldquo;email notifications&rdquo;&#31561;&#65292;&#28982;&#21518;&#28857;&#20987;&#25628;&#32034;&#25353;&#38062;&#12290;<\/p>\n<h3>&#27493;&#39588; 4: &#23433;&#35013;&#24182;&#28608;&#27963;&#26032;&#25554;&#20214;<\/h3>\n<p>&#25214;&#21040;&#31526;&#21512;&#38656;&#27714;&#30340;&#25554;&#20214;&#21518;&#65292;&#28857;&#20987;&ldquo;&#23433;&#35013;&rdquo;&#25353;&#38062;&#19979;&#36733;&#25554;&#20214;&#25991;&#20214;&#12290;&#23433;&#35013;&#23436;&#25104;&#21518;&#65292;&#28857;&#20987;&ldquo;&#28608;&#27963;&rdquo;&#25353;&#38062;&#26469;&#21551;&#29992;&#23427;&#12290;<\/p>\n<h3>&#27493;&#39588; 5: &#37197;&#32622;&#33258;&#21160;&#28404;&#28748;&#36890;&#30693;<\/h3>\n<p>&#25171;&#24320;&#25554;&#20214;&#35774;&#32622;&#39029;&#38754;&#65292;&#26681;&#25454;&#25552;&#31034;&#23436;&#25104;&#24517;&#35201;&#30340;&#37197;&#32622;&#12290;&#19968;&#33324;&#24773;&#20917;&#19979;&#65292;&#20320;&#38656;&#35201;&#22635;&#20889;&#20197;&#19979;&#20449;&#24687;&#65306;<\/p>\n<ul>\n<li><strong>&#36890;&#30693;&#31867;&#22411;<\/strong>&#65306;&#36873;&#25321;&#24744;&#24076;&#26395;&#36890;&#30693;&#30340;&#20869;&#23481;&#31867;&#22411;&#65292;&#27604;&#22914;&#25991;&#31456;&#21457;&#24067;&#12289;&#35780;&#35770;&#22238;&#22797;&#12289;&#27963;&#21160;&#24320;&#22987;&#31561;&#12290;<\/li>\n<li><strong>&#25509;&#25910;&#32773;<\/strong>&#65306;&#25351;&#23450;&#21738;&#20123;&#29992;&#25143;&#25110;&#35282;&#33394;&#24212;&#35813;&#25910;&#21040;&#36890;&#30693;&#12290;&#21487;&#20197;&#26159;&#25152;&#26377;&#29992;&#25143;&#12289;&#29305;&#23450;&#35282;&#33394;&#65288;&#22914;&#31649;&#29702;&#21592;&#65289;&#12289;&#35746;&#38405;&#21015;&#34920;&#31561;&#12290;<\/li>\n<li><strong>&#26102;&#38388;&#35302;&#21457;<\/strong>&#65306;&#35774;&#32622;&#36890;&#30693;&#20309;&#26102;&#21457;&#36865;&#12290;&#21487;&#20197;&#36873;&#25321;&#23450;&#26102;&#12289;&#27963;&#21160;&#24320;&#22987;&#21069;\/&#21518;&#31561;&#12290;<\/li>\n<li><strong>&#28040;&#24687;&#20869;&#23481;<\/strong>&#65306;&#22635;&#20889;&#36890;&#30693;&#20013;&#30340;&#20855;&#20307;&#20869;&#23481;&#65292;&#21253;&#25324;&#26631;&#39064;&#21644;&#27491;&#25991;&#12290;<\/li>\n<\/ul>\n<h3>&#31034;&#20363;&#20195;&#30721;<\/h3>\n<p>&#20551;&#35774;&#25105;&#20204;&#24819;&#21019;&#24314;&#19968;&#20010;&#33258;&#21160;&#36890;&#30693;&#65292;&#24403;&#26576;&#20010;&#24086;&#23376;&#34987;&#21457;&#24067;&#26102;&#65292;&#21457;&#36865;&#19968;&#26465;&#31616;&#30701;&#30340;&#36890;&#30693;&#32473;&#29305;&#23450;&#30340;&#35282;&#33394;&#12290;<\/p>\n<pre><code class=\"language-php\">\/\/ &#25554;&#20837;&#27492;&#20195;&#30721;&#20110;&#24744;&#30340;&#20027;&#39064;&#30340;functions.php&#25991;&#20214;&#20013;\nadd_action( 'publish_post', 'send_notification' );\n\nfunction send_notification() {\n    $post_id = get_the_ID();\n    $title = get_the_title();\n\n    \/\/ &#21457;&#36865;&#30005;&#23376;&#37038;&#20214;&#36890;&#30693;\n    wp_mail(\n        'admin@example.com',\n        'New Post Notification',\n        \"You have a new post titled '$title' on your site. Please visit the website to view it.\"\n    );\n}<\/code><\/pre>\n<h3>&#20351;&#29992;&#27493;&#39588;&#21450;&#25928;&#26524;<\/h3>\n<ol>\n<li>&#25171;&#24320;&#24744;&#30340; WordPress &#20027;&#39064;&#25991;&#20214;&#22841;&#65292;&#25214;&#21040;<code>functions.php<\/code>&#25991;&#20214;&#12290;<\/li>\n<li>&#23558;&#19978;&#36848;PHP&#20195;&#30721;&#28155;&#21152;&#21040;&#35813;&#25991;&#20214;&#30340;&#36866;&#24403;&#20301;&#32622;&#12290;<\/li>\n<li>&#20445;&#23384;&#25991;&#20214;&#24182;&#21047;&#26032;&#39029;&#38754;&#12290;<\/li>\n<\/ol>\n<p>&#29616;&#22312;&#65292;&#27599;&#24403;&#26377;&#26032;&#30340;&#24086;&#23376;&#21457;&#24067;&#26102;&#65292;&#31995;&#32479;&#20250;&#33258;&#21160;&#21521;&#25351;&#23450;&#30340;&#37038;&#31665;&#21457;&#36865;&#19968;&#26465;&#36890;&#30693;&#37038;&#20214;&#65292;&#21578;&#30693;&#31649;&#29702;&#21592;&#25110;&#29305;&#23450;&#29992;&#25143;&#26377;&#19968;&#26032;&#25991;&#31456;&#21457;&#24067;&#12290;<\/p>\n<p>&#36890;&#36807;&#36825;&#31181;&#26041;&#24335;&#65292;&#24744;&#21487;&#20197;&#26377;&#25928;&#22320;&#21033;&#29992;&#33258;&#21160;&#28404;&#28748;&#36890;&#30693;&#21151;&#33021;&#65292;&#25552;&#21319;&#29992;&#25143;&#20307;&#39564;&#21644;&#31038;&#21306;&#20114;&#21160;&#24615;&#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<h3>&#22914;&#20309;&#22312;WordPress&#20013;&#35774;&#32622;&#33258;&#21160;&#28404;&#28748;&#36890;&#30693;<\/h3>\n<p><strong>&#30446;&#26631;<\/strong>: &#22312;WordPress&#32593;&#31449;&#19978;&#23454;&#29616;&#33258;&#21160;&#21457;&#36865;&#28404;&#28748;&#36890;&#30693;&#21151;&#33021;&#12290;<\/p>\n<p><strong>&#20934;&#22791;&#38454;&#27573;<\/strong>:<\/p>\n<ul>\n<li>&#30830;&#20445;&#24744;&#30340;WordPress&#23433;&#35013;&#24050;&#27491;&#30830;&#37197;&#32622;&#12290;<\/li>\n<li>&#23433;&#35013;&#24182;&#28608;&#27963;&ldquo;WordPress&#28404;&#28748;&#36890;&#30693;&rdquo;&#25554;&#20214;&#65288;&#22914;&#26524;&#23578;&#26410;&#23433;&#35013;&#65289;&#12290;<\/li>\n<\/ul>\n<p><strong>&#27493;&#39588;1: &#20351;&#29992;WordPress&#20869;&#32622;&#21151;&#33021;<\/strong><\/p>\n<h4>1.1 &#21019;&#24314;&#36890;&#30693;&#27169;&#26495;<\/h4>\n<p>&#21019;&#24314;&#19968;&#20010;&#29992;&#20110;&#21457;&#36865;&#36890;&#30693;&#30340;&#27169;&#26495;&#25991;&#20214;&#12290;&#20363;&#22914;, &ldquo;notify.php&rdquo;&#12290;<\/p>\n<pre><code class=\"language-php\">&lt;?php\n\/\/ &#33719;&#21462;&#29992;&#25143;&#36755;&#20837;\n$subject = $_POST['subject'];\n$message = $_POST['message'];\n\n\/\/ &#21457;&#36865;&#30005;&#23376;&#37038;&#20214;\nmail('recipient@example.com', $subject, $message);\n?&gt;<\/code><\/pre>\n<h4>1.2 &#23558;&#37038;&#20214;&#21457;&#36865;&#21040;WordPress&#25968;&#25454;&#24211;<\/h4>\n<p>&#23558;&#19978;&#36848;PHP&#33050;&#26412;&#25554;&#20837;&#21040;&#20027;&#39064;&#30446;&#24405;&#19979;&#30340; <code>functions.php<\/code> &#25991;&#20214;&#20013;&#65292;&#28982;&#21518;&#36816;&#34892;&#20197;&#19979;&#20195;&#30721;&#65306;<\/p>\n<pre><code class=\"language-php\">add_action( 'wp_insert_comment', 'my_notify_function' );\nfunction my_notify_function( $comment_id ) {\n    \/\/ &#21462;&#24471;&#35780;&#35770;ID\n    $comment_id = get_comment_ID();\n\n    \/\/ &#39564;&#35777;&#26159;&#21542;&#20026;&#26032;&#35780;&#35770;\n    if ( ! wp_verify_nonce( $_POST['_wpnonce'], 'new-comment-nonce' ) || ! admin_bar_is_showing() ) {\n        return;\n    }\n\n    \/\/ &#26816;&#26597;&#26159;&#21542;&#20026;&#31649;&#29702;&#21592;\n    if (!current_user_can('edit_posts')) {\n        return;\n    }\n\n    \/\/ &#26816;&#26597;&#26159;&#21542;&#26377;&#36275;&#22815;&#30340;&#26435;&#38480;\n    if ( ! current_user_can('manage_options') &amp;&amp; ! is_admin() ) {\n        return;\n    }\n\n    \/\/ &#21019;&#24314;&#26032;&#30340;&#36890;&#30693;&#26465;&#30446;\n    wp_insert_post(array(\n        'post_title' =&gt; 'New Comment',\n        'post_content' =&gt; 'This is a new comment.',\n        'post_status' =&gt; 'publish',\n        'post_author' =&gt; get_current_user_id(),\n        'post_type' =&gt; 'notifications'\n    ));\n}<\/code><\/pre>\n<h4>1.3 &#35774;&#32622;&#33258;&#23450;&#20041;&#36890;&#30693;<\/h4>\n<p>&#22312; <code>functions.php<\/code> &#25991;&#20214;&#20013;&#28155;&#21152;&#33258;&#23450;&#20041;&#36890;&#30693;&#27169;&#26495;&#65292;&#20363;&#22914;:<\/p>\n<pre><code class=\"language-php\">add_action( 'wp_ajax_nopriv_my_notify_function', 'my_notify_function' );\nfunction my_notify_function() {\n    \/\/ &#20174;&#23458;&#25143;&#31471;&#33719;&#21462;&#28040;&#24687;&#21644;&#26631;&#39064;\n    $subject = $_POST['subject'];\n    $message = $_POST['message'];\n\n    \/\/ &#21019;&#24314;&#19968;&#20010;&#26032;&#30340;&#36890;&#30693;&#39033;\n    wp_insert_post(array(\n        'post_title' =&gt; $subject,\n        'post_content' =&gt; $message,\n        'post_status' =&gt; 'publish',\n        'post_author' =&gt; get_current_user_id()\n    ));\n}<\/code><\/pre>\n<p><strong>&#27979;&#35797;&#19982;&#39564;&#35777;<\/strong><\/p>\n<ul>\n<li>&#27979;&#35797;&#24744;&#30340;&#35774;&#32622;&#26159;&#21542;&#27491;&#24120;&#24037;&#20316;&#65292;&#30830;&#20445;&#27809;&#26377;&#36951;&#28431;&#20219;&#20309;&#37325;&#35201;&#20449;&#24687;&#25110;&#38169;&#35823;&#12290;<\/li>\n<li>&#22914;&#26524;&#38656;&#35201;&#65292;&#35831;&#36890;&#36807;&#31649;&#29702;&#21592;&#25511;&#21046;&#21488;&#26816;&#26597;&#25152;&#26377;&#21019;&#24314;&#30340;&#30005;&#23376;&#37038;&#20214;&#36890;&#30693;&#12290;<\/li>\n<\/ul>\n<p><strong>&#24635;&#32467;<\/strong>\n&#20197;&#19978;&#27493;&#39588;&#23637;&#31034;&#20102;&#22914;&#20309;&#22312;WordPress&#20013;&#20351;&#29992;&#20869;&#32622;&#21151;&#33021;&#21019;&#24314;&#21644;&#31649;&#29702;&#33258;&#21160;&#21270;&#36890;&#30693;&#12290;&#24744;&#21487;&#20197;&#36890;&#36807;&#20462;&#25913;&#27169;&#26495;&#12289;&#28155;&#21152;&#39069;&#22806;&#23383;&#27573;&#20197;&#21450;&#35843;&#25972;&#37038;&#31665;&#35774;&#32622;&#26469;&#36827;&#19968;&#27493;&#23450;&#21046;&#36825;&#20123;&#36890;&#30693;&#12290;&#36825;&#21482;&#26159;&#19968;&#20010;&#22522;&#30784;&#26694;&#26550;&#65292;&#24744;&#21487;&#20197;&#26681;&#25454;&#20855;&#20307;&#38656;&#27714;&#25193;&#23637;&#27492;&#27969;&#31243;&#20197;&#28385;&#36275;&#21508;&#31181;&#33258;&#21160;&#21270;&#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; &#22312; WordPress &#20013;&#35774;&#32622;&#33258;&#21160;&#28404;&#28748;&#36890;&#30693;&#65288;&#21363;&#33258;&#21160;&#21457;&#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-2332","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\/2332","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=2332"}],"version-history":[{"count":0,"href":"https:\/\/www.zhaozhao123.cn\/wpcms\/wp-json\/wp\/v2\/posts\/2332\/revisions"}],"wp:attachment":[{"href":"https:\/\/www.zhaozhao123.cn\/wpcms\/wp-json\/wp\/v2\/media?parent=2332"}],"wp:term":[{"taxonomy":"category","embeddable":true,"href":"https:\/\/www.zhaozhao123.cn\/wpcms\/wp-json\/wp\/v2\/categories?post=2332"},{"taxonomy":"post_tag","embeddable":true,"href":"https:\/\/www.zhaozhao123.cn\/wpcms\/wp-json\/wp\/v2\/tags?post=2332"},{"taxonomy":"tuisongtax","embeddable":true,"href":"https:\/\/www.zhaozhao123.cn\/wpcms\/wp-json\/wp\/v2\/tuisongtax?post=2332"}],"curies":[{"name":"wp","href":"https:\/\/api.w.org\/{rel}","templated":true}]}}