{"id":3949,"date":"2025-06-14T10:19:39","date_gmt":"2025-06-14T02:19:39","guid":{"rendered":"https:\/\/www.zhaozhao123.cn\/wpcms\/post\/3949.html"},"modified":"2025-06-14T11:44:26","modified_gmt":"2025-06-14T03:44:26","slug":"%e5%a6%82%e4%bd%95%e5%9c%a8-wordpress-%e4%b8%ad%e6%87%92%e5%8a%a0%e8%bd%bd%e8%af%84%e8%ae%ba","status":"publish","type":"post","link":"https:\/\/www.zhaozhao123.cn\/wpcms\/post\/3949.html","title":{"rendered":"\u5982\u4f55\u5728 WordPress \u4e2d\u61d2\u52a0\u8f7d\u8bc4\u8bba"},"content":{"rendered":"\r\n<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\u7231\u597d\u8005\" class=\"wp-image-1842\" style=\"object-fit:cover;width:30px;height:30px\"\/><\/figure>\r\n\r\n\r\n\r\n<h2 class=\"wp-block-heading my-0\" style=\"font-size:clamp(0.875rem, 0.875rem + ((1vw - 0.2rem) * 0.175), 1rem);\">Bug\u7231\u597d\u8005<\/h2>\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>\u4e3a\u4e86\u5728WordPress\u4e2d\u5b9e\u73b0\u61d2\u52a0\u8f7d\u8bc4\u8bba\u529f\u80fd\uff0c\u60a8\u9700\u8981\u9075\u5faa\u4ee5\u4e0b\u6b65\u9aa4\uff1a<\/p>\n<ol>\n<li>\n<p><strong>\u5b89\u88c5\u548c\u6fc0\u6d3b\u63d2\u4ef6<\/strong>\uff1a<\/p>\n<ul>\n<li>\u9996\u5148\uff0c\u786e\u4fdd\u60a8\u7684WordPress\u7f51\u7ad9\u5df2\u7ecf\u5b89\u88c5\u4e86<code>Lazy Load for Posts<\/code>\u63d2\u4ef6\u3002<\/li>\n<li>\u8fd9\u4e2a\u63d2\u4ef6\u53ef\u4ee5\u5e2e\u52a9\u60a8\u4f18\u5316\u9875\u9762\u52a0\u8f7d\u901f\u5ea6\uff0c\u5305\u62ec\u61d2\u52a0\u8f7d\u5e16\u5b50\u5185\u5bb9\u3002<\/li>\n<\/ul>\n<\/li>\n<li>\n<p><strong>\u8bbe\u7f6e\u8bc4\u8bba\u533a<\/strong>\uff1a<\/p>\n<ul>\n<li>\u5728\u4e3b\u9898\u6587\u4ef6\u5939\u4e2d\u627e\u5230<code>comments.php<\/code>\u6587\u4ef6\uff08\u5982\u679c\u60a8\u4f7f\u7528\u7684\u662f\u9ed8\u8ba4\u4e3b\u9898\uff09\uff0c\u6216\u8005\u521b\u5efa\u4e00\u4e2a\u65b0\u7684\u8bc4\u8bba\u6a21\u677f\u6587\u4ef6\uff0c\u4f8b\u5982<code>comment-single.php<\/code>\u3002<\/li>\n<li>\u6253\u5f00\u8be5\u6587\u4ef6\u5e76\u6dfb\u52a0\u4ee5\u4e0b\u4ee3\u7801\u6765\u542f\u7528\u61d2\u52a0\u8f7d\u8bc4\u8bba\uff1a\n<pre><code class=\"language-php\">&lt;div id=\"lazy-load-comment\"&gt;\n &lt;?php if ( have_comments() ) : ?&gt;\n     &lt;ol class=\"comment-list\"&gt;\n         &lt;?php wp_list_comments(array('style' =&gt; 'ul', 'callback' =&gt; 'my_comment_callback')); ?&gt;\n     &lt;\/ol&gt;\n &lt;?php endif; ?&gt;\n&lt;\/div&gt;<\/code><\/pre>\n<p>\u7136\u540e\uff0c\u5728<code>functions.php<\/code>\u6587\u4ef6\u4e2d\u5b9a\u4e49\u4e00\u4e2a\u51fd\u6570\u6765\u5904\u7406\u8bc4\u8bba\u5217\u8868\u7684\u6e32\u67d3\uff1a<\/p>\n<pre><code class=\"language-php\">function my_comment_callback($args) {\n global $post;\n echo '&lt;li id=\"' . $args['comment_ID'] . '\" class=\"comment\"&gt;';\n echo '&lt;article class=\"comment-body\"&gt;';\n printf('&lt;cite class=\"fn\"&gt;%s&lt;\/cite&gt;', get_comment_author_link());\n echo '&lt;time datetime=\"%1$s\" itemprop=\"datePublished\"&gt;&lt;abbr title=\"%2$s\"&gt;%3$s&lt;\/abbr&gt;&lt;\/time&gt;';\n echo '&lt;p&gt;%4$s&lt;\/p&gt;';\n echo '&lt;\/article&gt;';\n echo '&lt;footer class=\"comment-meta comment-author vcard\"&gt;';\n echo '&lt;a href=\"' . htmlspecialchars(get_comment_author_url()) . '\"&gt;' . esc_html__( 'Reply to this comment', 'your-theme-textdomain' ) . '&lt;\/a&gt;';\n echo '&lt;\/footer&gt;';\n echo '&lt;\/li&gt;';\n}<\/code><\/pre><\/li>\n<\/ul>\n<\/li>\n<li>\n<p><strong>\u8c03\u6574\u6837\u5f0f<\/strong>\uff1a<\/p>\n<ul>\n<li>\u4f7f\u7528CSS\u6837\u5f0f\u6765\u63a7\u5236\u61d2\u52a0\u8f7d\u6548\u679c\u3002\u53ef\u4ee5\u5728<code>functions.php<\/code>\u6587\u4ef6\u4e2d\u6dfb\u52a0\u4ee5\u4e0bCSS\u4ee3\u7801\uff1a\n<pre><code class=\"language-css\">#lazy-load-comment li.comment { opacity: 0; transition: all 0.5s ease-in-out; }\n#lazy-load-comment li:hover { opacity: 1; }<\/code><\/pre><\/li>\n<\/ul>\n<\/li>\n<li>\n<p><strong>\u6d4b\u8bd5\u4e0e\u8c03\u8bd5<\/strong>\uff1a<\/p>\n<ul>\n<li>\u6d4b\u8bd5\u60a8\u7684\u535a\u5ba2\u4ee5\u786e\u4fdd\u8bc4\u8bba\u533a\u6309\u9884\u671f\u663e\u793a\uff0c\u5e76\u4e14\u61d2\u52a0\u8f7d\u529f\u80fd\u6b63\u5e38\u5de5\u4f5c\u3002<\/li>\n<li>\u5982\u679c\u9047\u5230\u4efb\u4f55\u95ee\u9898\uff0c\u8bf7\u68c0\u67e5\u63d2\u4ef6\u662f\u5426\u5df2\u6b63\u786e\u5b89\u88c5\u548c\u6fc0\u6d3b\uff0c\u4ee5\u53ca\u6240\u6709\u5fc5\u8981\u7684\u6743\u9650\u8bbe\u7f6e\u3002<\/li>\n<\/ul>\n<\/li>\n<\/ol>\n<p>\u901a\u8fc7\u4ee5\u4e0a\u6b65\u9aa4\uff0c\u60a8\u5e94\u8be5\u80fd\u591f\u5728WordPress\u4e2d\u6210\u529f\u5b9e\u73b0\u61d2\u52a0\u8f7d\u8bc4\u8bba\u529f\u80fd\u3002\u8fd9\u4e0d\u4ec5\u6709\u52a9\u4e8e\u63d0\u5347\u7528\u6237\u4f53\u9a8c\uff0c\u8fd8\u80fd\u63d0\u9ad8\u7f51\u7ad9\u7684\u6574\u4f53\u6027\u80fd\u3002<\/p>\r\n<\/div>\r\n<\/div>\r\n<\/div>\r\n<\/div>\r\n\r\n\r\n\r\n<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=\"\u6cb3\u4e0aIT\u8bb2\u5e08\" class=\"wp-image-1849\" style=\"object-fit:cover;width:30px;height:30px\"\/><\/figure>\r\n\r\n\r\n\r\n<h2 class=\"wp-block-heading my-0\" style=\"font-size:clamp(0.875rem, 0.875rem + ((1vw - 0.2rem) * 0.175), 1rem);\">\u6cb3\u4e0aIT\u8bb2\u5e08<\/h2>\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>\u5728WordPress\u4e2d\u5b9e\u73b0\u61d2\u52a0\u8f7d\u8bc4\u8bba\u529f\u80fd\u53ef\u4ee5\u5e2e\u52a9\u63d0\u9ad8\u7f51\u7ad9\u6027\u80fd\u548c\u7528\u6237\u4f53\u9a8c\u3002\u61d2\u52a0\u8f7d\u662f\u4e00\u79cd\u4f18\u5316\u6280\u672f\uff0c\u5b83\u4f1a\u5728\u7528\u6237\u6eda\u52a8\u5230\u5143\u7d20\u65f6\u624d\u5f00\u59cb\u52a0\u8f7d\u5143\u7d20\u7684\u5185\u5bb9\u3002\u8fd9\u5bf9\u4e8e\u8bc4\u8bba\u533a\u5c24\u5176\u6709\u7528\uff0c\u56e0\u4e3a\u8bc4\u8bba\u901a\u5e38\u4f4d\u4e8e\u9875\u9762\u5e95\u90e8\uff0c\u5982\u679c\u7acb\u5373\u52a0\u8f7d\u5b83\u4eec\u53ef\u80fd\u4f1a\u5bfc\u81f4\u4e0d\u5fc5\u8981\u7684\u52a0\u8f7d\u65f6\u95f4\u3002<\/p>\n<p>\u4ee5\u4e0b\u662f\u5982\u4f55\u5728WordPress\u4e2d\u5b9e\u73b0\u61d2\u52a0\u8f7d\u8bc4\u8bba\u7684\u57fa\u672c\u6b65\u9aa4\uff1a<\/p>\n<ol>\n<li>\n<p><strong>\u5b89\u88c5\u5e76\u542f\u7528\u63d2\u4ef6<\/strong>\uff1a\u9996\u5148\uff0c\u4f60\u9700\u8981\u4e00\u4e2a\u8bc4\u8bba\u63d2\u4ef6\u6765\u5904\u7406\u8bc4\u8bba\u76f8\u5173\u7684\u5de5\u4f5c\uff0c\u5982\u663e\u793a\u3001\u7ba1\u7406\u7b49\u3002\u5bf9\u4e8e\u61d2\u52a0\u8f7d\u529f\u80fd\uff0c\u4f60\u53ef\u4ee5\u9009\u62e9\u4f7f\u7528<code>WP Lazy Load<\/code>\u63d2\u4ef6\u3002\u8fd9\u4e2a\u63d2\u4ef6\u53ef\u4ee5\u8ba9\u4f60\u8bbe\u7f6e\u54ea\u4e9b\u5185\u5bb9\u9700\u8981\u61d2\u52a0\u8f7d\u3002<\/p>\n<\/li>\n<li>\n<p><strong>\u6dfb\u52a0CSS\u6837\u5f0f<\/strong>\uff1a\u4e3a\u4e86\u5b9e\u73b0\u61d2\u52a0\u8f7d\u7684\u6548\u679c\uff0c\u4f60\u9700\u8981\u4e3a\u8bc4\u8bba\u533a\u57df\u6dfb\u52a0\u4e00\u4e9bCSS\u6837\u5f0f\u3002\u8fd9\u53ef\u4ee5\u901a\u8fc7\u4fee\u6539\u4e3b\u9898\u7684CSS\u6587\u4ef6\u6216\u8005\u4f7f\u7528\u5916\u90e8CSS\u6587\u4ef6\u6765\u5b8c\u6210\u3002\u4f8b\u5982\uff0c\u4f60\u53ef\u4ee5\u6dfb\u52a0\u5982\u4e0b\u4ee3\u7801\uff1a<\/p>\n<pre><code class=\"language-css\">.comments {\n   overflow: hidden;\n}\n\n.lazyload-comment img {\n   opacity: 0;\n   transition: opacity 0.5s ease-in-out;\n}<\/code><\/pre>\n<\/li>\n<li>\n<p><strong>\u914d\u7f6eLazyLoad\u9009\u9879<\/strong>\uff1a\u5728<code>WP Lazy Load<\/code>\u63d2\u4ef6\u7684\u8bbe\u7f6e\u4e2d\uff0c\u4f60\u53ef\u4ee5\u914d\u7f6e\u54ea\u4e9b\u8bc4\u8bba\u5e94\u8be5\u88ab\u61d2\u52a0\u8f7d\u3002\u9ed8\u8ba4\u60c5\u51b5\u4e0b\uff0c\u6240\u6709\u8bc4\u8bba\u90fd\u88ab\u8bbe\u4e3a\u61d2\u52a0\u8f7d\uff0c\u4f46\u4f60\u53ef\u4ee5\u6839\u636e\u9700\u8981\u8fdb\u884c\u8c03\u6574\u3002<\/p>\n<\/li>\n<li>\n<p><strong>\u66f4\u65b0\u4e3b\u9898<\/strong>\uff1a\u4fdd\u5b58\u66f4\u6539\u540e\uff0c\u8bb0\u5f97\u66f4\u65b0\u4f60\u7684\u4e3b\u9898\uff0c\u786e\u4fdd\u65b0\u7684CSS\u548cJS\u6587\u4ef6\u5df2\u7ecf\u751f\u6548\u3002<\/p>\n<\/li>\n<\/ol>\n<p>\u901a\u8fc7\u4ee5\u4e0a\u6b65\u9aa4\uff0c\u4f60\u5c31\u80fd\u591f\u5728WordPress\u4e2d\u6210\u529f\u5730\u5b9e\u73b0\u61d2\u52a0\u8f7d\u8bc4\u8bba\u529f\u80fd\u3002\u8fd9\u6837\u4e0d\u4ec5\u53ef\u4ee5\u63d0\u5347\u7528\u6237\u7684\u9605\u8bfb\u4f53\u9a8c\uff0c\u8fd8\u53ef\u4ee5\u51cf\u5c11\u670d\u52a1\u5668\u7684\u8d1f\u8f7d\uff0c\u4ece\u800c\u63d0\u9ad8\u7f51\u7ad9\u7684\u901f\u5ea6\u3002<\/p>\r\n<\/div>\r\n<\/div>\r\n<\/div>\r\n<\/div>\r\n\r\n\r\n\r\n<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--3\"><img decoding=\"async\" src=\"https:\/\/www.zhaozhao123.cn\/myitems\/images\/sites16\/2025\/06\/xygcfznnzczhsdmwydzhsmzzzmddnq-400x300.jpg\" alt=\"\u7801\u4e0a\u7761\u89c9\u55bd~\" class=\"wp-image-2906\" style=\"object-fit:cover;width:30px;height:30px\"\/><\/figure>\r\n\r\n\r\n\r\n<h2 class=\"wp-block-heading my-0\" style=\"font-size:clamp(0.875rem, 0.875rem + ((1vw - 0.2rem) * 0.175), 1rem);\">\u7801\u4e0a\u7761\u89c9\u55bd~<\/h2>\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>\u5982\u4f55\u5728 WordPress \u4e2d\u5b9e\u73b0\u61d2\u52a0\u8f7d\u8bc4\u8bba<\/h3>\n<h4>1. <strong>\u80cc\u666f\u4ecb\u7ecd<\/strong><\/h4>\n<p>\u5728\u73b0\u4ee3\u7f51\u7ad9\u8bbe\u8ba1\u4e2d\uff0c\u61d2\u52a0\u8f7d\u662f\u4e00\u79cd\u975e\u5e38\u53d7\u6b22\u8fce\u7684\u6280\u672f\uff0c\u5b83\u5141\u8bb8\u6211\u4eec\u5728\u5185\u5bb9\u52a0\u8f7d\u5230\u9875\u9762\u65f6\u624d\u52a0\u8f7d\u56fe\u7247\u548c\u5143\u7d20\u3002\u5bf9\u4e8e\u8bc4\u8bba\u90e8\u5206\uff0c\u540c\u6837\u53ef\u4ee5\u4f7f\u7528\u61d2\u52a0\u8f7d\u6280\u672f\u6765\u63d0\u9ad8\u7528\u6237\u4f53\u9a8c\u548c\u52a0\u8f7d\u901f\u5ea6\u3002<\/p>\n<h4>2. <strong>\u9700\u6c42\u5206\u6790<\/strong><\/h4>\n<ul>\n<li><strong>\u76ee\u6807<\/strong>\uff1a\u4f7f\u7528\u6237\u770b\u5230\u9875\u9762\u4e0a\u6240\u6709\u5185\u5bb9\uff0c\u5e76\u4e14\u4ec5\u5f53\u9700\u8981\u663e\u793a\u8bc4\u8bba\u65f6\u624d\u4f1a\u52a0\u8f7d\u8bc4\u8bba\u533a\u57df\u3002<\/li>\n<li><strong>\u6311\u6218<\/strong>\uff1a\u786e\u4fdd\u8bc4\u8bba\u533a\u57df\u5728\u8bc4\u8bba\u63d0\u4ea4\u540e\u7acb\u5373\u663e\u793a\uff0c\u540c\u65f6\u907f\u514d\u4e0d\u5fc5\u8981\u7684\u8d44\u6e90\u52a0\u8f7d\u3002<\/li>\n<\/ul>\n<h4>3. <strong>\u89e3\u51b3\u65b9\u6848<\/strong><\/h4>\n<p>\u4e3a\u4e86\u5b9e\u73b0\u8fd9\u4e00\u529f\u80fd\uff0c\u6211\u4eec\u53ef\u4ee5\u5229\u7528JavaScript\u4e2d\u7684<code>Intersection Observer API<\/code>\u3002\u8fd9\u4e2aAPI\u5141\u8bb8\u6211\u4eec\u76d1\u542cDOM\u5143\u7d20\u4e0e\u89c6\u53e3\u7684\u4f4d\u7f6e\u5173\u7cfb\u53d8\u5316\uff0c\u4ece\u800c\u52a8\u6001\u5730\u51b3\u5b9a\u4f55\u65f6\u52a0\u8f7d\u8d44\u6e90\u3002<\/p>\n<h5>\u4f7f\u7528\u65b9\u6cd5<\/h5>\n<p>\u9996\u5148\uff0c\u5728\u4f60\u7684WordPress\u4e3b\u9898\u6587\u4ef6\u5939\u4e0b\u521b\u5efa\u4e00\u4e2a\u540d\u4e3a<code>comment.php<\/code>\u7684\u65b0\u6587\u4ef6\uff08\u5982\u679c\u8fd8\u6ca1\u6709\u7684\u8bdd\uff09\uff0c\u7136\u540e\u5c06\u4ee5\u4e0b\u4ee3\u7801\u7c98\u8d34\u8fdb\u53bb\uff1a<\/p>\n<pre><code class=\"language-php\">&lt;?php\n$observer = new IntersectionObserver(function($entries, $observer) {\n    foreach ($entries as $entry) {\n        if ($entry.intersectionRatio &gt; 0) { \/\/ \u5f53\u5143\u7d20\u5b8c\u5168\u8fdb\u5165\u89c6\u53e3\u65f6\u89e6\u53d1\n            $entry.target.classList.add('loaded'); \/\/ \u6dfb\u52a0\u7c7b\u540d\u8868\u793a\u5df2\u52a0\u8f7d\n        }\n    }\n}, ['rootMargin' =&gt; '0px', 'threshold' =&gt; 0.5]);\n\n$observer-&gt;addEntry('#comments'); \/\/ \u76d1\u542c\u8bc4\u8bba\u533a\u57df\n?&gt;<\/code><\/pre>\n<p>\u5728\u8fd9\u4e2a\u4f8b\u5b50\u4e2d\uff0c\u6211\u4eec\u5c06\u76d1\u542cID\u4e3a<code>#comments<\/code>\u7684\u5143\u7d20\u3002\u5f53\u4f60\u6253\u5f00\u7f51\u9875\u5e76\u6eda\u52a8\u5230\u8be5\u5143\u7d20\u65f6\uff0c\u5b83\u5c31\u4f1a\u88ab\u6807\u8bb0\u4e3a\u5df2\u52a0\u8f7d\u72b6\u6001\u3002<\/p>\n<p>\u63a5\u4e0b\u6765\uff0c\u5728\u4f60\u7684\u4e3b\u9898\u7684<code>functions.php<\/code>\u6587\u4ef6\u4e2d\u6dfb\u52a0\u4ee5\u4e0b\u4ee3\u7801\uff0c\u4ee5\u4fbf\u5728\u8bc4\u8bba\u63d0\u4ea4\u540e\u81ea\u52a8\u66f4\u65b0\u8bc4\u8bba\u533a\u57df\u7684\u72b6\u6001\uff1a<\/p>\n<pre><code class=\"language-php\">function lazyload_comments() {\n    global $post;\n\n    $current_comment = get_comments(array(\n        'status' =&gt; 'approve',\n        'meta_key' =&gt; '_wp_http_referer',\n        'orderby' =&gt; 'comment_date',\n        'order' =&gt; 'ASC'\n    ));\n\n    foreach ($current_comment as $comment) {\n        $comment_id = $comment-&gt;comment_ID;\n\n        wp_update_comment(array(\n            'comment_ID' =&gt; $comment_id,\n            'comment_content' =&gt; ''\n        ));\n    }\n\n    update_post_meta(get_the_ID(), '_lazy_loaded_comments', true);\n}\nadd_action('save_post', 'lazyload_comments');<\/code><\/pre>\n<p>\u8fd9\u884c\u4ee3\u7801\u4f1a\u5728\u8bc4\u8bba\u63d0\u4ea4\u540e\u8c03\u7528<code>lazyload_comments()<\/code>\u51fd\u6570\uff0c\u8be5\u51fd\u6570\u4f1a\u6e05\u9664\u6240\u6709\u7684\u8bc4\u8bba\u5185\u5bb9\uff0c\u5e76\u8bbe\u7f6e\u5f53\u524d\u8bc4\u8bba\u533a\u57df\u4e3a\u5df2\u52a0\u8f7d\u72b6\u6001\u3002<\/p>\n<p>\u6700\u540e\uff0c\u5728\u4f60\u7684\u8bc4\u8bba\u6a21\u677f\u6587\u4ef6\uff08\u5982<code>single.php<\/code>\uff09\u4e2d\u52a0\u5165\u4ee5\u4e0bCSS\u6837\u5f0f\uff0c\u4f7f\u5176\u770b\u8d77\u6765\u66f4\u81ea\u7136\uff1a<\/p>\n<pre><code class=\"language-css\">.comments-container.loaded {\n    opacity: 1;\n    transition: opacity 0.5s ease-in-out;\n}\n\n.comments-container:not(.loaded) {\n    opacity: 0;\n}<\/code><\/pre>\n<p>\u8fd9\u6837\uff0c\u5f53\u8bc4\u8bba\u533a\u57df\u88ab\u6807\u8bb0\u4e3a\u5df2\u52a0\u8f7d\u65f6\uff0c\u5b83\u7684\u900f\u660e\u5ea6\u4f1a\u88ab\u589e\u52a0\uff0c\u4ece\u800c\u8ba9\u7528\u6237\u611f\u89c9\u8bc4\u8bba\u5df2\u7ecf\u663e\u793a\u51fa\u6765\u3002<\/p>\n<p>\u901a\u8fc7\u4ee5\u4e0a\u6b65\u9aa4\uff0c\u4f60\u5c31\u53ef\u4ee5\u5728WordPress\u4e2d\u8f7b\u677e\u5b9e\u73b0\u61d2\u52a0\u8f7d\u8bc4\u8bba\u7684\u529f\u80fd\u4e86\u3002\u8fd9\u79cd\u65b9\u6cd5\u4e0d\u4ec5\u63d0\u9ad8\u4e86\u7528\u6237\u4f53\u9a8c\uff0c\u8fd8\u4f18\u5316\u4e86\u9875\u9762\u52a0\u8f7d\u6027\u80fd\u3002<\/p>\r\n<\/div>\r\n<\/div>\r\n<\/div>\r\n<\/div>\r\n","protected":false},"excerpt":{"rendered":"<p>Bug\u7231\u597d\u8005 \u4e3a\u4e86\u5728WordPress\u4e2d\u5b9e\u73b0\u61d2\u52a0\u8f7d\u8bc4\u8bba\u529f\u80fd\uff0c\u60a8\u9700\u8981\u9075\u5faa\u4ee5\u4e0b\u6b65\u9aa4\uff1a \u5b89\u88c5\u548c\u6fc0\u6d3b\u63d2\u4ef6\uff1a \u9996\u5148\uff0c\u786e\u4fdd\u60a8\u7684WordPress\u7f51\u7ad9\u5df2\u7ecf\u5b89\u88c5\u4e86Lazy Load for Posts\u63d2\u4ef6\u3002 \u8fd9\u4e2a\u63d2\u4ef6\u53ef\u4ee5\u5e2e\u52a9\u60a8\u4f18\u5316\u9875\u9762\u52a0\u8f7d\u901f\u5ea6\uff0c\u5305\u62ec\u61d2\u52a0\u8f7d\u5e16\u5b50\u5185\u5bb9\u3002 \u8bbe\u7f6e\u8bc4\u8bba\u533a\uff1a \u5728\u4e3b\u9898\u6587\u4ef6\u5939\u4e2d\u627e\u5230comments.php\u6587\u4ef6\uff08\u5982\u679c\u60a8\u4f7f..<\/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":[3179],"tags":[3189,3190,3191],"tuisongtax":[],"class_list":["post-3949","post","type-post","status-publish","format-standard","hentry","category-wzjs","tag-zt","tag-yh","tag-wzyh"],"acf":[],"_links":{"self":[{"href":"https:\/\/www.zhaozhao123.cn\/wpcms\/wp-json\/wp\/v2\/posts\/3949","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=3949"}],"version-history":[{"count":0,"href":"https:\/\/www.zhaozhao123.cn\/wpcms\/wp-json\/wp\/v2\/posts\/3949\/revisions"}],"wp:attachment":[{"href":"https:\/\/www.zhaozhao123.cn\/wpcms\/wp-json\/wp\/v2\/media?parent=3949"}],"wp:term":[{"taxonomy":"category","embeddable":true,"href":"https:\/\/www.zhaozhao123.cn\/wpcms\/wp-json\/wp\/v2\/categories?post=3949"},{"taxonomy":"post_tag","embeddable":true,"href":"https:\/\/www.zhaozhao123.cn\/wpcms\/wp-json\/wp\/v2\/tags?post=3949"},{"taxonomy":"tuisongtax","embeddable":true,"href":"https:\/\/www.zhaozhao123.cn\/wpcms\/wp-json\/wp\/v2\/tuisongtax?post=3949"}],"curies":[{"name":"wp","href":"https:\/\/api.w.org\/{rel}","templated":true}]}}