{"id":3272,"date":"2025-06-11T20:20:23","date_gmt":"2025-06-11T12:20:23","guid":{"rendered":"https:\/\/www.zhaozhao123.cn\/wpcms\/wpdt\/3272.html"},"modified":"2025-06-11T20:20:23","modified_gmt":"2025-06-11T12:20:23","slug":"%e5%a6%82%e4%bd%95%e5%9c%a8wordpress%e4%b8%ad%e6%b7%bb%e5%8a%a0%e6%bb%9a%e5%8a%a8%e6%96%b0%e9%97%bb%e6%bb%9a%e5%8a%a8%e6%9d%a1","status":"publish","type":"post","link":"https:\/\/www.zhaozhao123.cn\/wpcms\/post\/3272.html","title":{"rendered":"\u5982\u4f55\u5728WordPress\u4e2d\u6dfb\u52a0\u6eda\u52a8\u65b0\u95fb\u6eda\u52a8\u6761"},"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;&#28378;&#21160;&#26032;&#38395;&#28378;&#21160;&#26465;&#21487;&#20197;&#25552;&#21319;&#32593;&#31449;&#30340;&#29992;&#25143;&#20307;&#39564;&#21644;&#39029;&#38754;&#21152;&#36733;&#36895;&#24230;&#12290;&#20197;&#19979;&#26159;&#22914;&#20309;&#23454;&#29616;&#36825;&#19968;&#21151;&#33021;&#30340;&#27493;&#39588;&#65306;<\/p>\n<h3>&#27493;&#39588; 1: &#28155;&#21152;&#21040;&#24744;&#30340; WordPress &#20027;&#39064;<\/h3>\n<p>&#39318;&#20808;&#65292;&#22312;&#24744;&#30340; WordPress &#20027;&#39064;&#25991;&#20214;&#22841;&#65288;&#22914; <code>functions.php<\/code>&#65289;&#20013;&#25214;&#21040;&#25110;&#21019;&#24314;&#19968;&#20010;&#21517;&#20026; <code>add-rolling-news.js<\/code> &#30340;&#26032; JavaScript &#25991;&#20214;&#12290;<\/p>\n<pre><code class=\"language-javascript\">\/\/ add-rolling-news.js\n(function($) {\n    \/\/ &#33719;&#21462;&#28378;&#21160;&#26032;&#38395;&#20803;&#32032;\n    var newsItems = $('.news-item');\n\n    \/\/ &#28378;&#21160;&#23450;&#26102;&#22120;\n    var scrollInterval = setInterval(function() {\n        \/\/ &#35745;&#31639;&#24403;&#21069;&#28378;&#21160;&#36317;&#31163;\n        var scrollTop = $(window).scrollTop();\n        \/\/ &#30830;&#20445;&#28378;&#21160;&#26465;&#19981;&#20250;&#36229;&#36807;&#31383;&#21475;&#39640;&#24230;\n        if (scrollTop + $(window).height() &gt;= $(document).height()) {\n            clearInterval(scrollInterval);\n        }\n\n        \/\/ &#31227;&#38500;&#26368;&#36817;&#30340;&#28378;&#21160;&#39033;\n        newsItems.last().remove();\n\n        \/\/ &#23558;&#19979;&#19968;&#20010;&#28378;&#21160;&#39033;&#28155;&#21152;&#21040;&#39030;&#37096;\n        newsItems.first().appendTo('.news-container');\n    }, 5000); \/\/ &#27599;5&#31186;&#26356;&#26032;&#19968;&#27425;\n})(jQuery);<\/code><\/pre>\n<h3>&#27493;&#39588; 2: &#21019;&#24314; HTML &#32467;&#26500;<\/h3>\n<p>&#30830;&#20445;&#24744;&#30340; WordPress &#39029;&#38754;&#26377;&#19968;&#20010;&#32467;&#26500;&#26469;&#23481;&#32435;&#28378;&#21160;&#26032;&#38395;&#12290;&#20363;&#22914;&#65292;&#24744;&#21487;&#20197;&#20026;&#27599;&#20010;&#26032;&#38395;&#39033;&#30446;&#21019;&#24314;&#19968;&#20010;&#31867;&#21517; <code>news-item<\/code> &#21644;&#19968;&#20010;&#23481;&#22120; <code>news-container<\/code>&#12290;<\/p>\n<pre><code class=\"language-html\">&lt;div class=\"news-container\"&gt;\n    &lt;div class=\"news-item\"&gt;News Item 1&lt;\/div&gt;\n    &lt;div class=\"news-item\"&gt;News Item 2&lt;\/div&gt;\n    &lt;!-- &#26356;&#22810;&#26032;&#38395;&#39033; --&gt;\n&lt;\/div&gt;<\/code><\/pre>\n<h3>&#27493;&#39588; 3: &#38142;&#25509; JS &#25991;&#20214;&#21040;&#24744;&#30340;&#39029;&#38754;<\/h3>\n<p>&#22312; WordPress &#39029;&#38754;&#30340;&#27169;&#26495;&#25991;&#20214;&#65288;&#22914; <code>single.php<\/code> &#25110; <code>page.php<\/code>&#65289;&#65292;&#36890;&#36807;&#20197;&#19979;&#26041;&#24335;&#38142;&#25509;&#21040;&#24744;&#21018;&#21018;&#21019;&#24314;&#30340; <code>add-rolling-news.js<\/code> &#25991;&#20214;&#65306;<\/p>\n<pre><code class=\"language-php\">&lt;!-- single.php &#25110; page.php --&gt;\n&lt;script src=\"&lt;?php echo get_template_directory_uri(); ?&gt;\/js\/add-rolling-news.js\"&gt;&lt;\/script&gt;<\/code><\/pre>\n<h3>&#27493;&#39588; 4: &#27979;&#35797;&#24182;&#20248;&#21270;<\/h3>\n<p>&#20445;&#23384;&#26356;&#25913;&#21518;&#65292;&#21047;&#26032;&#39029;&#38754;&#20197;&#26597;&#30475;&#28378;&#21160;&#26032;&#38395;&#26159;&#21542;&#25353;&#39044;&#26399;&#24037;&#20316;&#12290;&#26681;&#25454;&#23454;&#38469;&#38656;&#27714;&#35843;&#25972;&#38388;&#38548;&#26102;&#38388;&#12289;&#28378;&#21160;&#39033;&#25968;&#37327;&#31561;&#21442;&#25968;&#12290;<\/p>\n<h3>&#25928;&#26524;&#35828;&#26126;<\/h3>\n<p>&#24403;&#29992;&#25143;&#28378;&#21160;&#21040;&#39029;&#38754;&#24213;&#37096;&#26102;&#65292;JavaScript &#23450;&#26102;&#22120;&#20250;&#35302;&#21457;&#65292;&#20174; <code>news-container<\/code> &#20013;&#31227;&#38500;&#26368;&#21518;&#19968;&#20010;&#26032;&#38395;&#39033;&#24182;&#23558;&#20854;&#28155;&#21152;&#21040;&#39030;&#37096;&#12290;&#36825;&#26679;&#23601;&#23454;&#29616;&#20102;&#26032;&#38395;&#39033;&#30446;&#30340;&#33258;&#21160;&#28378;&#21160;&#26174;&#31034;&#12290;&#29992;&#25143;&#26080;&#38656;&#25163;&#21160;&#28378;&#21160;&#65292;&#25972;&#20010;&#39029;&#38754;&#20250;&#33258;&#21160;&#20445;&#25345;&#26368;&#26032;&#28040;&#24687;&#21487;&#35265;&#12290;<\/p>\n<p>&#36890;&#36807;&#36825;&#31181;&#26041;&#24335;&#65292;&#24744;&#19981;&#20165;&#25552;&#21319;&#20102;&#29992;&#25143;&#20307;&#39564;&#65292;&#36824;&#25552;&#39640;&#20102;&#32593;&#31449;&#24615;&#33021;&#65292;&#22240;&#20026;&#19981;&#38656;&#35201;&#39057;&#32321;&#22320;&#35831;&#27714;&#26032;&#30340;&#26032;&#38395;&#25968;&#25454;&#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;&#28155;&#21152;&#28378;&#21160;&#26032;&#38395;&#28378;&#21160;&#26465;&#26159;&#19968;&#31181;&#24120;&#35265;&#30340;&#35774;&#35745;&#20803;&#32032;&#65292;&#21487;&#20197;&#24110;&#21161;&#29992;&#25143;&#24555;&#36895;&#27983;&#35272;&#32593;&#31449;&#19978;&#30340;&#26368;&#26032;&#20869;&#23481;&#12290;&#20197;&#19979;&#26159;&#22914;&#20309;&#22312;WordPress&#20013;&#28155;&#21152;&#28378;&#21160;&#26032;&#38395;&#28378;&#21160;&#26465;&#30340;&#27493;&#39588;&#21644;&#31034;&#20363;&#20195;&#30721;&#12290;<\/p>\n<h3>&#27493;&#39588; 1: &#23433;&#35013;jQuery<\/h3>\n<p>&#39318;&#20808;&#65292;&#20320;&#38656;&#35201;&#23433;&#35013;jQuery&#24211;&#26469;&#25903;&#25345;JavaScript&#21151;&#33021;&#12290;&#20320;&#21487;&#20197;&#36890;&#36807;GitHub&#25110;CDN&#33719;&#21462;&#26368;&#26032;&#29256;&#26412;&#30340;jQuery&#65306;<\/p>\n<pre><code class=\"language-bash\">git clone https:\/\/github.com\/jquery\/jquery.git\ncd jquery\nnpm install<\/code><\/pre>\n<p>&#28982;&#21518;&#65292;&#22312;<code>wp-content\/plugins<\/code>&#30446;&#24405;&#19979;&#21019;&#24314;&#19968;&#20010;&#21517;&#20026;<code>jquery.js<\/code>&#30340;&#26032;&#25991;&#20214;&#24182;&#31896;&#36148;&#19978;&#36848;&#21629;&#20196;&#30340;&#32467;&#26524;&#21040;&#35813;&#25991;&#20214;&#20013;&#12290;<\/p>\n<h3>&#27493;&#39588; 2: &#28155;&#21152;jQuery&#25554;&#20214;<\/h3>\n<p>&#25509;&#19979;&#26469;&#65292;&#38656;&#35201;&#22312;WordPress&#20027;&#39064;&#20013;&#21551;&#29992;jQuery&#25554;&#20214;&#12290;&#21487;&#20197;&#36890;&#36807;&#32534;&#36753;<code>functions.php<\/code>&#25991;&#20214;&#20013;&#30340;<code>add_theme_support('core-js')<\/code>&#20989;&#25968;&#26469;&#23454;&#29616;&#65306;<\/p>\n<pre><code class=\"language-php\">function add_theme_support() {\n    wp_enqueue_style( 'bootstrap', get_template_directory_uri() . '\/css\/bootstrap.min.css' );\n    wp_enqueue_script( 'bootstrap', get_template_directory_uri() . '\/js\/bootstrap.bundle.min.js' );\n\n    wp_enqueue_script( 'jquery', get_template_directory_uri() . '\/js\/jquery.min.js' );\n}\nadd_action( 'after_setup_theme', 'add_theme_support' );<\/code><\/pre>\n<h3>&#27493;&#39588; 3: &#22312;&#25991;&#31456;&#39029;&#19978;&#28155;&#21152;&#28378;&#21160;&#26465;<\/h3>\n<p>&#35201;&#20026;&#21333;&#20010;&#25991;&#31456;&#39029;&#38754;&#28155;&#21152;&#28378;&#21160;&#26465;&#65292;&#21487;&#20197;&#20351;&#29992;<code>&lt;div class=\"news-scroll\"&gt;<\/code>&#26631;&#31614;&#26469;&#23450;&#20041;&#28378;&#21160;&#21306;&#22495;&#12290;&#21516;&#26102;&#65292;&#38656;&#35201;&#20351;&#29992;<code>&lt;script&gt;<\/code>&#26631;&#31614;&#23558;jQuery&#33050;&#26412;&#28155;&#21152;&#21040;&#30456;&#24212;&#30340;&#20301;&#32622;&#20197;&#21551;&#21160;&#28378;&#21160;&#25928;&#26524;&#12290;<\/p>\n<pre><code class=\"language-html\">&lt;div class=\"news-scroll\"&gt;\n    &lt;h2&gt;&#26631;&#39064;&lt;\/h2&gt;\n    &lt;article&gt;\n        &lt;div class=\"post-content\"&gt;\n            &lt;!-- &#25991;&#31456;&#27491;&#25991; --&gt;\n        &lt;\/div&gt;\n    &lt;\/article&gt;\n&lt;\/div&gt;\n\n&lt;script src=\"&lt;?php echo get_template_directory_uri(); ?&gt;\/js\/news-scroll.js\"&gt;&lt;\/script&gt;<\/code><\/pre>\n<h3>&#31034;&#20363;&#20195;&#30721;&#65306;news-scroll.js<\/h3>\n<p>&#19979;&#38754;&#26159;&#19968;&#20010;&#31616;&#21333;&#30340;&#28378;&#21160;&#26465;&#31034;&#20363;&#20195;&#30721;&#65306;<\/p>\n<pre><code class=\"language-javascript\">\/\/ &#33719;&#21462;&#24403;&#21069;&#25991;&#31456;ID\nconst articleId = \"&lt;?php the_ID(); ?&gt;\";\n\n\/\/ &#35774;&#32622;&#28378;&#21160;&#26465;&#23485;&#24230;&#65288;&#20363;&#22914;&#65292;&#35774;&#32622;&#20026;100%&#65289;\nconst scrollWidth = \"100%\";\n\n\/\/ &#21019;&#24314;&#28378;&#21160;&#26465;&#26679;&#24335;\nconst scrollStyle = `\n    width: ${scrollWidth};\n`;\n\n\/\/ &#21019;&#24314;&#28378;&#21160;&#26465;&#21160;&#30011;\nconst animationDuration = \"500ms\";\nconst animationEase = \"easeInOutQuad\";\n\n\/\/ &#23558;&#26679;&#24335;&#24212;&#29992;&#21040;&#25991;&#31456;&#27491;&#25991;\ndocument.getElementById(articleId).style.scrollContainerStyle = scrollStyle;\ndocument.getElementById(articleId).style.animationName = `NewsScrollAnimation`;\ndocument.getElementById(articleId).style.animationDuration = `${animationDuration}ms`;\ndocument.getElementById(articleId).style.animationEasing = `${animationEase}`;<\/code><\/pre>\n<h3>&#32467;&#35770;<\/h3>\n<p>&#20197;&#19978;&#23601;&#26159;&#22312;WordPress&#20013;&#28155;&#21152;&#28378;&#21160;&#26032;&#38395;&#28378;&#21160;&#26465;&#30340;&#22522;&#26412;&#27493;&#39588;&#12290;&#26681;&#25454;&#23454;&#38469;&#38656;&#27714;&#35843;&#25972;CSS&#21644;JavaScript&#20195;&#30721;&#20197;&#36866;&#24212;&#19981;&#21516;&#30340;&#24067;&#23616;&#21644;&#39118;&#26684;&#12290;&#24076;&#26395;&#36825;&#20010;&#20363;&#23376;&#23545;&#20320;&#26377;&#25152;&#24110;&#21161;&#65281;&#22914;&#26524;&#20320;&#26377;&#20219;&#20309;&#30097;&#38382;&#65292;&#35831;&#38543;&#26102;&#25552;&#38382;&#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;&#28378;&#21160;&#26032;&#38395;&#28378;&#21160;&#26465;&#21487;&#20197;&#25552;&#21319;&#038;#3..<\/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-3272","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\/3272","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=3272"}],"version-history":[{"count":0,"href":"https:\/\/www.zhaozhao123.cn\/wpcms\/wp-json\/wp\/v2\/posts\/3272\/revisions"}],"wp:attachment":[{"href":"https:\/\/www.zhaozhao123.cn\/wpcms\/wp-json\/wp\/v2\/media?parent=3272"}],"wp:term":[{"taxonomy":"category","embeddable":true,"href":"https:\/\/www.zhaozhao123.cn\/wpcms\/wp-json\/wp\/v2\/categories?post=3272"},{"taxonomy":"post_tag","embeddable":true,"href":"https:\/\/www.zhaozhao123.cn\/wpcms\/wp-json\/wp\/v2\/tags?post=3272"},{"taxonomy":"tuisongtax","embeddable":true,"href":"https:\/\/www.zhaozhao123.cn\/wpcms\/wp-json\/wp\/v2\/tuisongtax?post=3272"}],"curies":[{"name":"wp","href":"https:\/\/api.w.org\/{rel}","templated":true}]}}