{"id":3619,"date":"2025-06-12T01:58:21","date_gmt":"2025-06-11T17:58:21","guid":{"rendered":"https:\/\/www.zhaozhao123.cn\/wpcms\/wpdt\/3619.html"},"modified":"2025-06-12T01:58:21","modified_gmt":"2025-06-11T17:58:21","slug":"%e5%a6%82%e4%bd%95%e5%9c%a8wordpress%e4%b8%ad%e6%b7%bb%e5%8a%a0%e7%a7%af%e5%88%86%e7%b3%bb%e7%bb%9f%e4%bb%a5%e6%bf%80%e5%8f%91%e7%94%a8%e6%88%b7%e5%8f%82%e4%b8%8e%e5%ba%a6","status":"publish","type":"post","link":"https:\/\/www.zhaozhao123.cn\/wpcms\/post\/3619.html","title":{"rendered":"\u5982\u4f55\u5728WordPress\u4e2d\u6dfb\u52a0\u79ef\u5206\u7cfb\u7edf\u4ee5\u6fc0\u53d1\u7528\u6237\u53c2\u4e0e\u5ea6"},"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;&#28155;&#21152;&#31215;&#20998;&#31995;&#32479;&#21487;&#20197;&#24110;&#21161;&#25552;&#39640;&#29992;&#25143;&#30340;&#21442;&#19982;&#24230;&#21644;&#24544;&#35802;&#24230;&#12290;&#36825;&#31181;&#31215;&#20998;&#31995;&#32479;&#21487;&#20197;&#22522;&#20110;&#29992;&#25143;&#30340;&#27963;&#21160;&#12289;&#36141;&#20080;&#34892;&#20026;&#25110;&#32773;&#27880;&#20876;&#26102;&#38388;&#26469;&#22686;&#21152;&#20182;&#20204;&#30340;&#31215;&#20998;&#12290;&#20197;&#19979;&#26159;&#22914;&#20309;&#22312;WordPress&#20013;&#23454;&#29616;&#36825;&#20010;&#21151;&#33021;&#30340;&#27493;&#39588;&#12290;<\/p>\n<h3>&#27493;&#39588; 1: &#23433;&#35013;&#24182;&#28608;&#27963;&#25554;&#20214;<\/h3>\n<p>&#39318;&#20808;&#65292;&#22312;WordPress&#21518;&#21488;&#30340;&ldquo;&#25554;&#20214;&rdquo;&#39029;&#38754;&#25214;&#21040;&#24182;&#23433;&#35013;&#19968;&#20010;&#31215;&#20998;&#31995;&#32479;&#30340;&#25554;&#20214;&#12290;&#20363;&#22914;&#65292;&ldquo;&#31215;&#28857;&#31995;&#32479;&rdquo;&#65288;Points System&#65289;&#25110;&#31867;&#20284;&#30340;&#25554;&#20214;&#12290;&#28982;&#21518;&#65292;&#28608;&#27963;&#35813;&#25554;&#20214;&#12290;<\/p>\n<h3>&#27493;&#39588; 2: &#37197;&#32622;&#31215;&#20998;&#35268;&#21017;<\/h3>\n<p>&#30331;&#24405;&#21040;&#24744;&#30340;WordPress&#31649;&#29702;&#38754;&#26495;&#65292;&#23548;&#33322;&#21040;&ldquo;&#31215;&#28857;&#31995;&#32479;&rdquo;&#35774;&#32622;&#12290;&#22312;&#36825;&#37324;&#65292;&#24744;&#21487;&#20197;&#36890;&#36807;&#33258;&#23450;&#20041;&#31215;&#20998;&#35268;&#21017;&#20026;&#19981;&#21516;&#30340;&#27963;&#21160;&#35774;&#32622;&#31215;&#20998;&#20540;&#12290;&#20363;&#22914;&#65292;&#24744;&#21487;&#20197;&#35774;&#23450;&#29992;&#25143;&#27599;&#38405;&#35835;&#19968;&#31687;&#25991;&#31456;&#33719;&#24471;5&#20010;&#31215;&#20998;&#65292;&#25110;&#32773;&#27599;&#36141;&#20080;&#21830;&#21697;&#33719;&#24471;100&#20010;&#31215;&#20998;&#12290;<\/p>\n<h3>&#31034;&#20363;&#20195;&#30721;&#65306;<\/h3>\n<pre><code class=\"language-php\">\/\/ &#22312;functions.php&#25991;&#20214;&#20013;&#28155;&#21152;&#27492;&#20195;&#30721;&#27573;\nfunction add_points() {\n    \/\/ &#27599;&#38405;&#35835;&#19968;&#31687;&#25991;&#31456;&#22686;&#21152;5&#20010;&#31215;&#20998;\n    if (is_single()) {\n        update_user_meta(get_current_user_id(), 'points', get_post_meta($post-&gt;ID, '_wp_page_template', true) == 'single.php' ? current_user_can('edit_posts') ? $current_user-&gt;ID : 0 : 5);\n    }\n}\nadd_action('save_post', 'add_points');<\/code><\/pre>\n<p>&#36825;&#27573;&#20195;&#30721;&#20250;&#22312;&#29992;&#25143;&#38405;&#35835;&#21333;&#20010;&#25991;&#31456;&#26102;&#22686;&#21152;&#30456;&#24212;&#30340;&#31215;&#20998;&#12290;&#35831;&#26681;&#25454;&#24744;&#30340;&#38656;&#27714;&#35843;&#25972;&#31215;&#20998;&#35268;&#21017;&#12290;<\/p>\n<h3>&#27493;&#39588; 3: &#21033;&#29992;&#31215;&#20998;&#22870;&#21169;&#29992;&#25143;<\/h3>\n<p>&#19968;&#26086;&#31215;&#20998;&#34987;&#21019;&#24314;&#65292;&#23601;&#21487;&#20197;&#36890;&#36807;&#31215;&#20998;&#21830;&#22478;&#25110;&#20854;&#20182;&#26041;&#24335;&#28608;&#21169;&#29992;&#25143;&#20351;&#29992;&#36825;&#20123;&#31215;&#20998;&#12290;&#27604;&#22914;&#65292;&#29992;&#25143;&#21487;&#20197;&#29992;&#31215;&#20998;&#20817;&#25442;&#20248;&#24800;&#21048;&#65292;&#25110;&#32773;&#22312;&#29305;&#23450;&#26085;&#26399;&#21069;&#20351;&#29992;&#31215;&#20998;&#36141;&#20080;&#20248;&#24800;&#21830;&#21697;&#12290;<\/p>\n<h3>&#32467;&#35770;<\/h3>\n<p>&#36890;&#36807;&#19978;&#36848;&#27493;&#39588;&#65292;&#24744;&#21487;&#20197;&#25104;&#21151;&#22320;&#22312;WordPress&#20013;&#28155;&#21152;&#31215;&#20998;&#31995;&#32479;&#65292;&#20174;&#32780;&#25552;&#21319;&#29992;&#25143;&#20307;&#39564;&#21644;&#20114;&#21160;&#24615;&#12290;&#31215;&#20998;&#19981;&#20165;&#33021;&#22815;&#22686;&#24378;&#31038;&#21306;&#31896;&#24615;&#21644;&#29992;&#25143;&#24544;&#35802;&#24230;&#65292;&#36824;&#33021;&#20419;&#36827;&#38144;&#21806;&#21644;&#33829;&#38144;&#27963;&#21160;&#30340;&#26377;&#25928;&#25191;&#34892;&#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;&#21019;&#24314;&#31215;&#20998;&#31995;&#32479;&#21487;&#20197;&#26497;&#22823;&#22320;&#25552;&#21319;&#29992;&#25143;&#30340;&#21442;&#19982;&#24230;&#21644;&#24544;&#35802;&#24230;&#12290;&#20197;&#19979;&#26159;&#19968;&#20123;&#22522;&#26412;&#27493;&#39588;&#21644;&#31034;&#20363;&#20195;&#30721;&#26469;&#24110;&#21161;&#24744;&#23454;&#29616;&#36825;&#20010;&#30446;&#26631;&#65306;<\/p>\n<h3>1. &#23433;&#35013;&#24182;&#37197;&#32622;&#31215;&#20998;&#25554;&#20214;<\/h3>\n<p>&#39318;&#20808;&#65292;&#22312;&#24744;&#30340;WordPress&#32593;&#31449;&#19978;&#23433;&#35013;&#19968;&#20010;&#25903;&#25345;&#31215;&#20998;&#21151;&#33021;&#30340;&#25554;&#20214;&#12290;&#25512;&#33616;&#20351;&#29992;&ldquo;WP User Points&rdquo;&#25110;&ldquo;WooCommerce Points&rdquo;&#31561;&#25554;&#20214;&#65292;&#22240;&#20026;&#23427;&#20204;&#25552;&#20379;&#20102;&#20016;&#23500;&#30340;&#35774;&#32622;&#36873;&#39033;&#21644;&#26131;&#20110;&#38598;&#25104;&#30340;&#21151;&#33021;&#12290;<\/p>\n<h4>&#31034;&#20363;&#20195;&#30721;&#65306;<\/h4>\n<pre><code class=\"language-php\">\/\/ WP User Points &#25554;&#20214;\nadd_action('admin_init', 'wp_user_points_setup');\nfunction wp_user_points_setup() {\n    register_plugin_hook(plugins_url('\/wp-user-points.php'), 'plugin_name', 'setup_wp_user_points');\n}\n\nfunction setup_wp_user_points($hook) {\n    add_theme_support('wc-product-gallery-zoom');\n    add_theme_support('wc-product-gallery-lightbox');\n    add_theme_support('wc-product-gallery-slider');\n}<\/code><\/pre>\n<h4>&#31034;&#20363;&#20195;&#30721;&#65306;<\/h4>\n<pre><code class=\"language-html\">&lt;!-- &#22312;woocommerce&#20135;&#21697;&#39029;&#38754;&#26174;&#31034;&#31215;&#20998; --&gt;\n&lt;div class=\"product-attribute\"&gt;\n    &lt;div class=\"attribute-label\"&gt;&#31215;&#20998;&#65306;&lt;\/div&gt;\n    &lt;span&gt;&lt;?php echo wc_get_product_attribute_value('points'); ?&gt;&lt;\/span&gt;\n&lt;\/div&gt;<\/code><\/pre>\n<h3>2. &#35774;&#32622;&#31215;&#20998;&#35268;&#21017;<\/h3>\n<p>&#25509;&#19979;&#26469;&#65292;&#26681;&#25454;&#24744;&#30340;&#38656;&#27714;&#35774;&#32622;&#31215;&#20998;&#35268;&#21017;&#12290;&#20363;&#22914;&#65292;&#24744;&#21487;&#20197;&#20026;&#19981;&#21516;&#30340;&#36141;&#20080;&#34892;&#20026;&#65288;&#22914;&#19968;&#27425;&#36141;&#20080;&#12289;&#22810;&#27425;&#36141;&#20080;&#65289;&#20998;&#37197;&#31215;&#20998;&#20540;&#12290;&#36825;&#20123;&#35268;&#21017;&#21487;&#20197;&#22312;WordPress&#21518;&#21488;&#36890;&#36807;&#25554;&#20214;&#25110;&#33258;&#23450;&#20041;&#20027;&#39064;&#25991;&#20214;&#36827;&#34892;&#35774;&#32622;&#12290;<\/p>\n<h4>&#31034;&#20363;&#20195;&#30721;&#65306;<\/h4>\n<pre><code class=\"language-php\">\/\/ &#33258;&#23450;&#20041;&#20027;&#39064;&#25991;&#20214;&#65306;&#35774;&#32622;&#31215;&#20998;&#35268;&#21017;\nfunction custom_product_attributes( $attributes ) {\n    if ( 'WC_Product' === get_post_type() &amp;&amp; ! empty( $_POST['custom_attribute'] ) ) {\n        \/\/ &#33719;&#21462;&#25351;&#23450;&#30340;&#21830;&#21697;ID\n        $product_id = sanitize_text_field($_POST['custom_attribute']);\n\n        \/\/ &#26816;&#26597;&#21830;&#21697;&#26159;&#21542;&#23384;&#22312;\n        if ( has_term( 'WC_Product_Attribute', 'product_tag', array( $product_id, 'attribute_name' ), false ) ) {\n            \/\/ &#20998;&#37197;&#31215;&#20998;&#21040;&#21830;&#21697;\n            $points = intval( $_POST['points'] );\n            update_post_meta( $product_id, 'points', $points );\n        } else {\n            \/\/ &#38169;&#35823;&#22788;&#29702;\n        }\n    }\n\n    return $attributes;\n}\nadd_filter( 'woocommerce_before_add_to_cart_button', 'custom_product_attributes', 10, 2 );<\/code><\/pre>\n<h3>3. &#20351;&#29992;&#31215;&#20998;&#31995;&#32479;&#28608;&#21169;&#29992;&#25143;<\/h3>\n<p>&#26368;&#21518;&#65292;&#23558;&#31215;&#20998;&#31995;&#32479;&#19982;&#32593;&#31449;&#19978;&#30340;&#20854;&#20182;&#20803;&#32032;&#30456;&#32467;&#21512;&#65292;&#28608;&#21169;&#29992;&#25143;&#23436;&#25104;&#29305;&#23450;&#20219;&#21153;&#25110;&#25552;&#20379;&#21453;&#39304;&#12290;&#20363;&#22914;&#65292;&#27599;&#24403;&#29992;&#25143;&#25552;&#20132;&#35746;&#21333;&#26102;&#65292;&#20182;&#20204;&#21487;&#20197;&#33719;&#24471;&#19968;&#23450;&#25968;&#37327;&#30340;&#31215;&#20998;&#65307;&#27599;&#24403;&#29992;&#25143;&#21457;&#24067;&#35780;&#35770;&#26102;&#65292;&#20182;&#20204;&#20063;&#21487;&#20197;&#33719;&#24471;&#31215;&#20998;&#12290;<\/p>\n<h4>&#31034;&#20363;&#20195;&#30721;&#65306;<\/h4>\n<pre><code class=\"language-php\">\/\/ &#26356;&#26032;&#31215;&#20998;&#34920;&#21333;\nfunction update_points_form($form) {\n    $form['submit']['value'] = __('Submit', 'my-plugin') . ' &amp;raquo; ' . __('Points', 'my-plugin');\n\n    return $form;\n}\n\nadd_filter('woocommerce_checkout_update_after_fields', 'update_points_form');<\/code><\/pre>\n<p>&#36890;&#36807;&#20197;&#19978;&#27493;&#39588;&#65292;&#24744;&#21487;&#20197;&#26377;&#25928;&#22320;&#22312;WordPress&#20013;&#28155;&#21152;&#31215;&#20998;&#31995;&#32479;&#65292;&#20174;&#32780;&#25552;&#39640;&#29992;&#25143;&#30340;&#21442;&#19982;&#24230;&#21644;&#24544;&#35802;&#24230;&#12290;&#35831;&#30830;&#20445;&#22312;&#23454;&#26045;&#20219;&#20309;&#26032;&#30340;&#21151;&#33021;&#20043;&#21069;&#65292;&#23545;&#26032;&#21151;&#33021;&#36827;&#34892;&#20805;&#20998;&#27979;&#35797;&#65292;&#20197;&#30830;&#20445;&#20854;&#27491;&#30830;&#24615;&#21644;&#31283;&#23450;&#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; &#22312;WordPress&#20013;&#28155;&#21152;&#31215;&#20998;&#31995;&#32479;&#21487;&#20197;&#24110;&#21161;&#25552;&#39640;&#29992;&#038;#2..<\/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":[2107,2106],"tuisongtax":[],"class_list":["post-3619","post","type-post","status-publish","format-standard","hentry","category-wpdt","tag-cjyy","tag-cjzn"],"acf":[],"_links":{"self":[{"href":"https:\/\/www.zhaozhao123.cn\/wpcms\/wp-json\/wp\/v2\/posts\/3619","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=3619"}],"version-history":[{"count":0,"href":"https:\/\/www.zhaozhao123.cn\/wpcms\/wp-json\/wp\/v2\/posts\/3619\/revisions"}],"wp:attachment":[{"href":"https:\/\/www.zhaozhao123.cn\/wpcms\/wp-json\/wp\/v2\/media?parent=3619"}],"wp:term":[{"taxonomy":"category","embeddable":true,"href":"https:\/\/www.zhaozhao123.cn\/wpcms\/wp-json\/wp\/v2\/categories?post=3619"},{"taxonomy":"post_tag","embeddable":true,"href":"https:\/\/www.zhaozhao123.cn\/wpcms\/wp-json\/wp\/v2\/tags?post=3619"},{"taxonomy":"tuisongtax","embeddable":true,"href":"https:\/\/www.zhaozhao123.cn\/wpcms\/wp-json\/wp\/v2\/tuisongtax?post=3619"}],"curies":[{"name":"wp","href":"https:\/\/api.w.org\/{rel}","templated":true}]}}