{"id":2414,"date":"2025-06-11T02:04:34","date_gmt":"2025-06-10T18:04:34","guid":{"rendered":"https:\/\/www.zhaozhao123.cn\/wpcms\/wpdt\/2414.html"},"modified":"2025-06-11T02:04:34","modified_gmt":"2025-06-10T18:04:34","slug":"%e5%a6%82%e4%bd%95%e5%9c%a8wordpress%e4%b8%ad%e9%80%9a%e7%9f%a5%e8%ae%a2%e9%98%85%e8%80%85%e6%96%b0%e6%96%87%e7%ab%a0%ef%bc%883%e7%a7%8d%e6%96%b9%e6%b3%95%ef%bc%89","status":"publish","type":"post","link":"https:\/\/www.zhaozhao123.cn\/wpcms\/post\/2414.html","title":{"rendered":"\u5982\u4f55\u5728WordPress\u4e2d\u901a\u77e5\u8ba2\u9605\u8005\u65b0\u6587\u7ae0\uff083\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;&#20026;&#35746;&#38405;&#32773;&#25552;&#20379;&#26032;&#25991;&#31456;&#30340;&#36890;&#30693;&#26159;&#19968;&#31181;&#24120;&#35265;&#30340;&#21151;&#33021;&#38656;&#27714;&#12290;&#26377;&#22810;&#31181;&#26041;&#24335;&#21487;&#20197;&#23454;&#29616;&#36825;&#19968;&#30446;&#26631;&#65292;&#20197;&#19979;&#26159;&#19977;&#31181;&#24120;&#29992;&#30340;&#26041;&#27861;&#65306;&#30005;&#23376;&#37038;&#20214;&#36890;&#30693;&#12289;RSS Feed&#26356;&#26032;&#21644;&#36890;&#36807;WordPress&#30340;&#37038;&#20214;&#25554;&#20214;&#21457;&#36865;&#36890;&#30693;&#12290;<\/p>\n<h3>&#26041;&#27861;&#19968;&#65306;&#30005;&#23376;&#37038;&#20214;&#36890;&#30693;<\/h3>\n<ol>\n<li>\n<p><strong>&#21019;&#24314;&#36890;&#30693;&#27169;&#26495;<\/strong>&#65306;<\/p>\n<ul>\n<li>&#30331;&#24405;&#21040;&#24744;&#30340;WordPress&#31649;&#29702;&#21518;&#21488;&#12290;<\/li>\n<li>&#36827;&#20837;<code>&#35774;&#32622; &gt; &#21457;&#36865;&#36890;&#30693;<\/code>&#39029;&#38754;&#12290;<\/li>\n<li>&#36873;&#25321;&#24744;&#24819;&#35201;&#21457;&#36865;&#30340;&#36890;&#30693;&#31867;&#22411;&#65288;&#22914;&ldquo;&#26032;&#25991;&#31456;&rdquo;&#25110;&ldquo;&#26032;&#35780;&#35770;&rdquo;&#65289;&#65292;&#28982;&#21518;&#28857;&#20987;&ldquo;&#26032;&#24314;&#36890;&#30693;&rdquo;&#25353;&#38062;&#12290;<\/li>\n<li>&#22312;&#24377;&#20986;&#30340;&#31383;&#21475;&#20013;&#65292;&#24744;&#21487;&#20197;&#22635;&#20889;&#26631;&#39064;&#12289;&#25551;&#36848;&#20197;&#21450;&#20219;&#20309;&#38468;&#21152;&#20449;&#24687;&#65292;&#26368;&#21518;&#28857;&#20987;&#20445;&#23384;&#12290;<\/li>\n<\/ul>\n<\/li>\n<li>\n<p><strong>&#23450;&#21046;&#37038;&#20214;&#27169;&#26495;<\/strong>&#65306;<\/p>\n<ul>\n<li>&#22312;&ldquo;&#32534;&#36753;&rdquo;&#36873;&#39033;&#21345;&#19979;&#65292;&#24744;&#21487;&#20197;&#19978;&#20256;&#25110;&#21019;&#24314;&#33258;&#23450;&#20041;&#30340;&#37038;&#20214;&#27169;&#26495;&#12290;&#36825;&#19968;&#27493;&#39588;&#20801;&#35768;&#24744;&#26681;&#25454;&#38656;&#35201;&#35843;&#25972;&#37038;&#20214;&#30340;&#20869;&#23481;&#12290;<\/li>\n<\/ul>\n<\/li>\n<li>\n<p><strong>&#27979;&#35797;&#36890;&#30693;<\/strong>&#65306;<\/p>\n<ul>\n<li>&#21019;&#24314;&#36890;&#30693;&#21518;&#65292;&#24744;&#21487;&#20197;&#21333;&#20987;&#36890;&#30693;&#26049;&#36793;&#30340;&ldquo;&#27979;&#35797;&rdquo;&#38142;&#25509;&#26469;&#26597;&#30475;&#23427;&#26159;&#21542;&#25353;&#39044;&#26399;&#24037;&#20316;&#12290;<\/li>\n<\/ul>\n<\/li>\n<li>\n<p><strong>&#21457;&#24067;&#36890;&#30693;<\/strong>&#65306;<\/p>\n<ul>\n<li>&#24403;&#24744;&#20934;&#22791;&#22909;&#21457;&#24067;&#36890;&#30693;&#26102;&#65292;&#22312;&ldquo;&#29366;&#24577;&rdquo;&#23383;&#27573;&#20013;&#36873;&#25321;&ldquo;&#24050;&#21457;&#24067;&rdquo;&#12290;<\/li>\n<\/ul>\n<\/li>\n<\/ol>\n<h3>&#31034;&#20363;&#20195;&#30721;&#65306;<\/h3>\n<p>&#20551;&#35774;&#25105;&#20204;&#27491;&#22312;&#21019;&#24314;&#19968;&#20010;&#26032;&#30340;&#20851;&#20110;&ldquo;&#26032;&#25991;&#31456;&rdquo;&#30340;&#30005;&#23376;&#37038;&#20214;&#36890;&#30693;&#12290;<\/p>\n<pre><code class=\"language-php\">\/\/ &#39318;&#20808;&#65292;&#30830;&#20445;&#22312;functions.php&#25991;&#20214;&#20013;&#28155;&#21152;&#20197;&#19979;&#20195;&#30721;&#20197;&#21551;&#29992;&#37038;&#20214;&#36890;&#30693;\nfunction notify_new_articles() {\n    $email = get_option('notify_email'); \/\/ &#33719;&#21462;&#37197;&#32622;&#22909;&#30340;&#37038;&#31665;&#22320;&#22336;\n    if (empty($email)) return; \/\/ &#22914;&#26524;&#27809;&#26377;&#37197;&#32622;&#37038;&#31665;&#65292;&#21017;&#36820;&#22238;\n\n    add_action('wp', 'send_new_article_notification');\n}\nadd_action('init', 'notify_new_articles');\n\n\/\/ &#23450;&#20041;&#37038;&#20214;&#27169;&#26495;&#20989;&#25968;\nfunction send_new_article_notification() {\n    global $wpdb;\n    $articles = $wpdb-&gt;get_results(\"SELECT ID, post_title FROM wp_posts WHERE post_status='publish' AND post_type='post'\");\n\n    foreach ($articles as $article) {\n        $subject = \"New Article: {$article-&gt;post_title}\";\n        $message = \"&lt;p&gt;New article has been published:&lt;\/p&gt;&lt;a href='\" . esc_url(get_permalink($article-&gt;ID)) . \"'&gt;Read More&lt;\/a&gt;\";\n\n        wp_mail($email, $subject, $message);\n    }\n}\n\n\/\/ &#27979;&#35797;&#36890;&#30693;\nsend_new_article_notification();<\/code><\/pre>\n<p>&#36825;&#27573;&#20195;&#30721;&#20250;&#22312;WordPress&#21021;&#22987;&#21270;&#26102;&#36816;&#34892;&#65292;&#24182;&#22312;&#27599;&#31687;&#25991;&#31456;&#21457;&#24067;&#21518;&#21521;&#25351;&#23450;&#30340;&#37038;&#31665;&#21457;&#36865;&#19968;&#26465;&#31616;&#30701;&#30340;&#36890;&#30693;&#12290;<\/p>\n<h3>&#27880;&#24847;&#20107;&#39033;&#65306;<\/h3>\n<ul>\n<li>&#30830;&#20445;&#24744;&#30340;&#37038;&#20214;&#26381;&#21153;&#22120;&#25903;&#25345;SMTP&#21327;&#35758;&#65292;&#24182;&#19988;&#24050;&#32463;&#27491;&#30830;&#37197;&#32622;&#20102;SMTP&#26381;&#21153;&#22120;&#30340;&#20449;&#24687;&#12290;<\/li>\n<li>&#32771;&#34385;&#21040;&#23433;&#20840;&#24615;&#65292;&#19981;&#35201;&#20844;&#24320;&#24744;&#30340;&#37038;&#20214;&#26381;&#21153;&#22120;&#30340;&#29992;&#25143;&#21517;&#21644;&#23494;&#30721;&#65292;&#32780;&#26159;&#21487;&#20197;&#36890;&#36807;SSL\/TLS&#21152;&#23494;&#30340;&#26041;&#24335;&#20256;&#36882;&#36825;&#20123;&#20449;&#24687;&#12290;<\/li>\n<li>&#23545;&#20110;&#22823;&#22411;&#31449;&#28857;&#65292;&#21487;&#33021;&#38656;&#35201;&#32771;&#34385;&#20351;&#29992;&#26356;&#22797;&#26434;&#30340;&#23433;&#20840;&#25514;&#26045;&#65292;&#20363;&#22914;&#20351;&#29992;PHPMailer&#31561;&#24211;&#26469;&#22788;&#29702;&#37038;&#20214;&#21457;&#36865;&#12290;<\/li>\n<\/ul>\n<p>&#36890;&#36807;&#19978;&#36848;&#26041;&#27861;&#65292;&#24744;&#21487;&#20197;&#36731;&#26494;&#22320;&#22312;WordPress&#20013;&#20026;&#35746;&#38405;&#32773;&#25552;&#20379;&#26032;&#25991;&#31456;&#30340;&#36890;&#30693;&#26381;&#21153;&#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;&#36890;&#30693;&#35746;&#38405;&#32773;&#26032;&#25991;&#31456;&#30340;&#26041;&#27861;&#26377;&#24456;&#22810;&#65292;&#36825;&#37324;&#25105;&#23558;&#21521;&#24744;&#20171;&#32461;&#19977;&#31181;&#19981;&#21516;&#30340;&#26041;&#27861;&#65306;<\/p>\n<h3>&#26041;&#27861;1&#65306;&#20351;&#29992;WordPress&#20869;&#32622;&#30340;&#37038;&#20214;&#21151;&#33021;<\/h3>\n<h4>&#35821;&#27861;&#65306;<\/h4>\n<ul>\n<li>\n<p><strong>&#21457;&#36865;&#19968;&#20010;&#30005;&#23376;&#37038;&#20214;<\/strong>&#65306;<code>wp_mail( 'recipient@example.com', 'Subject of the email', 'Message here' );<\/code><\/p>\n<\/li>\n<li>\n<p><strong>&#21457;&#36865;&#19968;&#20010;&#26032;&#38395;&#37038;&#20214;<\/strong>&#65306;<code>wp_send_newpost_notification();<\/code><\/p>\n<\/li>\n<\/ul>\n<h4>&#31034;&#20363;&#20195;&#30721;&#65306;<\/h4>\n<pre><code class=\"language-php\">\/\/ &#20351;&#29992;WordPress&#20869;&#32622;&#30340;&#37038;&#20214;&#21151;&#33021;&#21457;&#36865;&#26032;&#25991;&#31456;&#37038;&#20214;\n$to = 'subscriber@example.com';\n$subject = 'New article published!';\n$message = \"Congratulations! A new article has been published on your blog.\";\nwp_mail($to, $subject, $message);<\/code><\/pre>\n<p>&#22312;&#36825;&#20010;&#20363;&#23376;&#20013;&#65292;&#25105;&#20204;&#39318;&#20808;&#23450;&#20041;&#20102;&#21457;&#20214;&#20154;&#12289;&#20027;&#39064;&#21644;&#28040;&#24687;&#12290;&#28982;&#21518;&#65292;&#25105;&#20204;&#35843;&#29992;<code>wp_mail()<\/code>&#20989;&#25968;&#26469;&#21457;&#36865;&#30005;&#23376;&#37038;&#20214;&#12290;<\/p>\n<h3>&#26041;&#27861;2&#65306;&#20351;&#29992;WordPress&#25554;&#20214;&#25110;&#20027;&#39064;&#25552;&#20379;&#30340;API<\/h3>\n<h4>&#25554;&#20214;&#31034;&#20363;&#65306;<\/h4>\n<ul>\n<li><strong>WPML&#36890;&#30693;&#25554;&#20214;<\/strong>&#65306;<a href=\"https:\/\/www.zhaozhao123.cn\/skin\/go?url=aHR0cHM6Ly9naXRodWIuY29tL3dvcmRwcmVzcy93cG1sLW5vdGlmaWNhdGlvbnM=\" rel=\"noopener noreferrer nofollow\">WPMU-Notify<\/a><\/li>\n<li><strong>WPML&#36890;&#30693;&#20027;&#39064;<\/strong>&#65306;<a href=\"https:\/\/www.zhaozhao123.cn\/skin\/go?url=aHR0cHM6Ly93b3JkcHJlc3Mub3JnL3BsdWdpbnMvd3BtdS1ub3RpZmljYXRpb25zLw==\" rel=\"noopener noreferrer nofollow\">WPML Theme Notifications<\/a><\/li>\n<li><strong>WPML&#36890;&#30693;&#36890;&#30693;&#20013;&#24515;<\/strong>&#65306;<a href=\"https:\/\/www.zhaozhao123.cn\/skin\/go?url=aHR0cHM6Ly93b3JkcHJlc3Mub3JnL3BsdWdpbnMvd3BtdS1ub3RpZmljYXRpb24tY2VudGVyLw==\" rel=\"noopener noreferrer nofollow\">WPML Notification Center<\/a><\/li>\n<\/ul>\n<p>&#36825;&#20123;&#25554;&#20214;&#21644;&#20027;&#39064;&#37117;&#25552;&#20379;&#20102;&#21457;&#36865;&#26032;&#25991;&#31456;&#30340;&#36890;&#30693;&#21151;&#33021;&#12290;&#20363;&#22914;&#65292;&#20320;&#21487;&#20197;&#21019;&#24314;&#19968;&#20010;&#33258;&#23450;&#20041;&#30340;&#20027;&#39064;&#65292;&#20854;&#20013;&#21253;&#21547;&#19968;&#20010;&#36890;&#30693;&#21306;&#22495;&#65292;&#27599;&#24403;&#26377;&#26032;&#30340;&#25991;&#31456;&#21457;&#24067;&#26102;&#65292;&#23427;&#20250;&#26174;&#31034;&#19968;&#26465;&#36890;&#30693;&#28040;&#24687;&#12290;<\/p>\n<h4>&#31034;&#20363;&#20195;&#30721;&#65306;<\/h4>\n<pre><code class=\"language-php\">\/\/ &#20351;&#29992;WPML&#36890;&#30693;&#25554;&#20214;&#21457;&#36865;&#26032;&#25991;&#31456;&#37038;&#20214;\nrequire_once('path\/to\/WPML_Notification.php');\n$notifier = new WPML_Notification();\n$notifier-&gt;notify(\n    array(\n        'type' =&gt; 'new_post',\n        'title' =&gt; 'A new post has been published!',\n        'content' =&gt; 'The latest post on your blog is now live.',\n    )\n);\n\n\/\/ &#25110;&#32773;&#65292;&#20351;&#29992;WPML&#36890;&#30693;&#20027;&#39064;\n$theme = get_template();\nif (strpos($theme, 'your_theme_name') !== false) {\n    wp_enqueue_style('wpml-theme-notifications', plugins_url('\/wpml-theme-notifications.css'), ['wpml-theme-notifications']);\n    wp_enqueue_script('wpml-theme-notifications', plugins_url('\/wpml-theme-notifications.js'), ['wpml-theme-notifications'], null, true);\n}\n?&gt;<\/code><\/pre>\n<h3>&#26041;&#27861;3&#65306;&#20351;&#29992;&#31532;&#19977;&#26041;API&#25110;&#26381;&#21153;<\/h3>\n<h4>&#31034;&#20363;&#20195;&#30721;&#65306;<\/h4>\n<pre><code class=\"language-javascript\">\/\/ &#20351;&#29992;SendGrid API&#21457;&#36865;&#37038;&#20214;\nconst sgMail = require('@sendgrid\/mail');\n\nsgMail.setApiKey(process.env.SENDGRID_API_KEY);\nconst msg = {\n    to: 'recipient@example.com',\n    from: 'admin@example.com',\n    subject: 'New article published!',\n    text: 'Congratulations! A new article has been published on your blog.',\n};\n\nsgMail.send(msg).then(() =&gt; console.log(\"Email sent successfully\"));<\/code><\/pre>\n<p>&#36825;&#20010;&#20363;&#23376;&#23637;&#31034;&#20102;&#22914;&#20309;&#20351;&#29992;SendGrid API&#21457;&#36865;&#19968;&#23553;&#21253;&#21547;&#26032;&#25991;&#31456;&#26631;&#39064;&#21644;&#20869;&#23481;&#30340;&#37038;&#20214;&#12290;&#20320;&#38656;&#35201;&#22312;&#39033;&#30446;&#20013;&#35774;&#32622;SENDGRID_API_KEY&#29615;&#22659;&#21464;&#37327;&#12290;<\/p>\n<p>&#36890;&#36807;&#20197;&#19978;&#19977;&#31181;&#26041;&#27861;&#20013;&#30340;&#20219;&#20309;&#19968;&#31181;&#65292;&#37117;&#21487;&#20197;&#22312;WordPress&#20013;&#20026;&#35746;&#38405;&#32773;&#21457;&#36865;&#26032;&#25991;&#31456;&#36890;&#30693;&#12290;&#36873;&#25321;&#26368;&#21512;&#36866;&#30340;&#26041;&#26696;&#21462;&#20915;&#20110;&#24744;&#30340;&#20855;&#20307;&#38656;&#27714;&#21644;&#20559;&#22909;&#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;&#20026;&#35746;&#38405;&#32773;&#25552;&#20379;&#26032;&#25991;&#31456;&#30340;&#36890;&#30693;&#26159;&#038;#1..<\/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":[59],"tuisongtax":[],"class_list":["post-2414","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\/2414","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=2414"}],"version-history":[{"count":0,"href":"https:\/\/www.zhaozhao123.cn\/wpcms\/wp-json\/wp\/v2\/posts\/2414\/revisions"}],"wp:attachment":[{"href":"https:\/\/www.zhaozhao123.cn\/wpcms\/wp-json\/wp\/v2\/media?parent=2414"}],"wp:term":[{"taxonomy":"category","embeddable":true,"href":"https:\/\/www.zhaozhao123.cn\/wpcms\/wp-json\/wp\/v2\/categories?post=2414"},{"taxonomy":"post_tag","embeddable":true,"href":"https:\/\/www.zhaozhao123.cn\/wpcms\/wp-json\/wp\/v2\/tags?post=2414"},{"taxonomy":"tuisongtax","embeddable":true,"href":"https:\/\/www.zhaozhao123.cn\/wpcms\/wp-json\/wp\/v2\/tuisongtax?post=2414"}],"curies":[{"name":"wp","href":"https:\/\/api.w.org\/{rel}","templated":true}]}}