首頁 CMS教程 &#&按 wordpress怎麼實現文章分頁

wordpress怎麼實現文章分頁

Dec 25, 2019 am 10:50 AM
wordpress

wordpress怎麼實現文章分頁

wordpress怎麼實作文章分頁?

由於篇幅過長導致頁面載入速度過慢,降低使用者體驗,所以必須要找個方法把長文章進行分頁,搜尋了一下,發現有個程式碼解決的方法非常好。經過親自使用,確實有效,所以在這裡分享出來,感興趣的你可不要錯過了哈

  推薦:《wordpress教程#》

最近發現有不少文章配上圖片,寫得比較長。這樣會導致頁面載入速度過慢,不利於使用者體驗。尤其是新加入的 wordpress主題 頁面,雖然文字不多,可是每個wordpress主題都要配上個小圖片,才能讓讀者有個大概的了解。從而決定是否要進行示範。那麼將近三十款wordpress主題加在一起,頁面就非常的長。所以必須要找個方法把長文章分頁。 

在Google上搜尋了一下,發現有個程式碼解決的方法非常好。經過親自使用,確實有效,所以在這裡分享出來。 

一、新增分頁按鈕 

如果你不怕麻煩的話,可以在寫文章的時候,切換到HTML模式,插入下面這行程式碼,就不需要新增這個分頁按鈕了。 

程式碼如下:

<p><!--nextpage--></p>
登入後複製

其實還是在編輯器上新增個分頁按鈕省事多了。以前也看過透過修改程式碼來實在這個功能,不過我忘了。因為我一直都用 wordpress編輯器增強外掛:TinyMCE Advanced 。這個按鈕早就有了,這裡也不多說了。

2012-06-17補充:給WordPress 3.4 文字編輯器新增分頁按鈕 

由於我的「非誠勿擾女嘉賓資料」 fc.guansoft.com 網站也用了這篇文章中介紹的長文章分頁代碼。但那個站沒有安裝 TinyMCE Advanced 外掛。所以還是上網找了個比較簡單的方法在wordpress編輯器中加入這個分頁按鈕。方法如下: 

找到 /wp-includes/class-wp-editor.php 檔案。尋找 ‘wp_more’, 標籤:(在366行) 

程式碼如下:

$mce_buttons = apply_filters(&#39;mce_buttons&#39;, array(&#39;bold&#39;, &#39;italic&#39;, &#39;strikethrough&#39;, &#39;¦&#39;, &#39;bullist&#39;, &#39;numlist&#39;, &#39;blockquote&#39;, &#39;¦&#39;, &#39;justifyleft&#39;, &#39;justifycenter&#39;, &#39;justifyright&#39;, &#39;¦&#39;, &#39;link&#39;, &#39;unlink&#39;, <SPAN style="TEXT-DECORATION: underline"><STRONG><SPAN style="COLOR: #ff0000; TEXT-DECORATION: underline">&#39;wp_more&#39;,</SPAN></STRONG></SPAN> &#39;¦&#39;, &#39;spellchecker&#39;, &#39;fullscreen&#39;, &#39;wp_adv&#39; ), $editor_id);
登入後複製

在 ‘wp_more’ 後面加上 ‘wp_page’,(含單引號和逗號)。修改後程式碼如下: 

程式碼如下:

$mce_buttons = apply_filters(&#39;mce_buttons&#39;, array(&#39;bold&#39;, &#39;italic&#39;, &#39;strikethrough&#39;, &#39;¦&#39;, &#39;bullist&#39;, &#39;numlist&#39;, &#39;blockquote&#39;, &#39;¦&#39;, &#39;justifyleft&#39;, &#39;justifycenter&#39;, &#39;justifyright&#39;, &#39;¦&#39;, &#39;link&#39;, &#39;unlink&#39;, <SPAN style="TEXT-DECORATION: underline"><STRONG><SPAN style="COLOR: #ff0000; TEXT-DECORATION: underline">&#39;wp_more&#39;,&#39;wp_page&#39;,</SPAN></STRONG></SPAN> &#39;¦&#39;, &#39;spellchecker&#39;, &#39;fullscreen&#39;, &#39;wp_adv&#39; ), $editor_id);
登入後複製

此時,你就可以在後台寫文章及編輯文章頁面的文字編輯器上看到一個跟more 標籤按鈕相似的圖示。 

同樣,在程式碼編輯器也會對應出現一個 nextpage 按鈕。 

二、新增分頁功能 

wordpress其實自備分頁功能的函數,只是沒有被呼叫。所以我們在編輯文章的時候,明明插入了分頁符,卻看不到什麼變化。要怎麼樣才能讓呼叫這個函數呢?方法很簡單,在主題模板檔案 single.php 中找到類似下面這行程式碼。 

程式碼如下:

<?php the_content(); ?>
登入後複製

在這行程式碼後面加上如下所示的程式碼,即可實現簡單的分頁功能。 

程式碼如下:

<?php wp_link_pages(); ?>
登入後複製

三、美化分頁效果 

雖然經過上面兩步,已經可以實現長文章的分頁功能了。但不是那麼好看,下面我們就把它美化一下,讓分頁效果更完美。 

首先,把上一個步驟的分頁功能碼 替換為以下程式碼。 

程式碼如下:

<?php wp_link_pages(array(&#39;before&#39; => &#39;<div class="fenye">分页阅读:&#39;, &#39;after&#39; => &#39;&#39;, &#39;next_or_number&#39; => &#39;next&#39;, &#39;previouspagelink&#39; => &#39;上一页&#39;, &#39;nextpagelink&#39; => "")); ?> <?php wp_link_pages(array(&#39;before&#39; => &#39;&#39;, &#39;after&#39; => &#39;&#39;, &#39;next_or_number&#39; => &#39;number&#39;, &#39;link_before&#39; =>&#39;<span>&#39;, &#39;link_after&#39;=>&#39;</span>&#39;)); ?> <?php wp_link_pages(array(&#39;before&#39; => &#39;&#39;, &#39;after&#39; => &#39;</div>&#39;, &#39;next_or_number&#39; => &#39;next&#39;, &#39;previouspagelink&#39; => &#39;&#39;, &#39;nextpagelink&#39; => "下一页")); ?>
登入後複製

接著,再對CSS樣式進行美化。 

直接把下面這些程式碼,放到主題檔 style.css 最後面。

程式碼如下:

/**页面分页**/ 
.fenye{text-align:center;margin:0px auto 10px;font-weight:bold} 
.fenye span{background-color:#DDDDDD;color:#fff;font-weight: bold;margin:0px 1px;padding:1px 6px;display:inline-block;text-decoration:none;border:1px solid #e0e0e0;} 
.fenye a{text-decoration:none;} 
.fenye a span{background-color:#F6F6E8;font-weight: normal;color: #000;text-decoration: none;} 
.fenye a:hover span{background-color:#DDDDDD;color: #fff;}
登入後複製

最後顯示效果如下圖所示: 

wordpress怎麼實現文章分頁

#四、解決文章分頁後標題重複對SEO的影響 

由於長文章分頁後,這幾頁的標題是一樣的。會不會對SEO帶來不利的影響,我也不清楚。還是避免一下吧!可以透過為 wordpress 文章分頁加上頁碼,解決標題重複的問題。我們可以把改成如下所示的效果: 

簡單實用的wordpress長文章分頁代碼—冠朔wordpress插件 

簡單實用的wordpress長文章分頁代碼-第2頁— 冠朔wordpress外掛 

簡單實用的wordpress長文章分頁程式碼-第3頁— 冠朔wordpress外掛 

在主題範本檔案header.php 找到類似…</ title> 代碼,將其替換為如下代碼。 </p><p>程式碼如下:</p><div class="code" style="position:relative; padding:0px; margin:0px;"><pre class='brush:php;toolbar:false;'><?php if ( is_single() ) { ?><title><?php echo trim(wp_title(&#39;&#39;,0)); ?><?php if (get_query_var(&#39;page&#39;)) { echo &#39;-第&#39;; echo get_query_var(&#39;page&#39;); echo &#39;页&#39;;}?> — <?php bloginfo(&#39;name&#39;); ?></title><?php } ?></pre><div class="contentsignin">登入後複製</div></div><p>五、避免Feed被分頁 </p><p>實現分頁功能後,會導致Feed頁面的文章被分頁,一般只顯示第一頁的內容。 </p><p>解決方法:打開wp-includes 目錄下的query.php 文件,找到下面這行程式碼(大概在3578行) </p><p>程式碼如下:</p><div class="code" style="position:relative; padding:0px; margin:0px;"><pre class='brush:php;toolbar:false;'>if ( strpos( $content,&#39;<!–nextpage–>&#39; ) ) {</pre><div class="contentsignin">登入後複製</div></div><p>把它修改為下面這行程式碼。 </p><p>程式碼如下:</p><div class="code" style="position:relative; padding:0px; margin:0px;"><pre class='brush:php;toolbar:false;'>if ( strpos( $content, &#39;<!--nextpage-->&#39; ) && (!is_feed()) ) {</pre><div class="contentsignin">登入後複製</div></div><p>更多WordPress相关技术文章,请访问<strong>WordPress</strong>教程栏目:https://www.php.cn/cms/wordpress/</p><p>以上是wordpress怎麼實現文章分頁的詳細內容。更多資訊請關注PHP中文網其他相關文章!</p> </div> </div> <div class="wzconShengming_sp"> <div class="bzsmdiv_sp">本網站聲明</div> <div>本文內容由網友自願投稿,版權歸原作者所有。本站不承擔相應的法律責任。如發現涉嫌抄襲或侵權的內容,請聯絡admin@php.cn</div> </div> </div> <ins class="adsbygoogle" style="display:block" data-ad-format="autorelaxed" data-ad-client="ca-pub-5902227090019525" data-ad-slot="2507867629"></ins> <script> (adsbygoogle = window.adsbygoogle || []).push({}); </script> <div class="AI_ToolDetails_main4sR"> <ins class="adsbygoogle" style="display:block" data-ad-client="ca-pub-5902227090019525" data-ad-slot="3653428331" data-ad-format="auto" data-full-width-responsive="true"></ins> <script> (adsbygoogle = window.adsbygoogle || []).push({}); </script> <!-- <div class="phpgenera_Details_mainR4"> <div class="phpmain1_4R_readrank"> <div class="phpmain1_4R_readrank_top"> <img onerror="this.onerror=''; this.src='/static/imghw/default1.png'" onerror="this.onerror=''; this.src='/static/imghw/default1.png'" src="/static/imghw/hotarticle2.png" alt="" /> <h2>熱門文章</h2> </div> <div class="phpgenera_Details_mainR4_bottom"> <div class="phpgenera_Details_mainR4_bottoms"> <a href="https://www.php.cn/zh-tw/faq/1796789525.html" title="Windows 11 KB5054979中的新功能以及如何解決更新問題" class="phpgenera_Details_mainR4_bottom_title">Windows 11 KB5054979中的新功能以及如何解決更新問題</a> <div class="phpgenera_Details_mainR4_bottoms_info"> <span>3 週前</span> <span>By DDD</span> </div> </div> <div class="phpgenera_Details_mainR4_bottoms"> <a href="https://www.php.cn/zh-tw/faq/1796793874.html" title="如何修復KB5055523無法在Windows 11中安裝?" class="phpgenera_Details_mainR4_bottom_title">如何修復KB5055523無法在Windows 11中安裝?</a> <div class="phpgenera_Details_mainR4_bottoms_info"> <span>2 週前</span> <span>By DDD</span> </div> </div> <div class="phpgenera_Details_mainR4_bottoms"> <a href="https://www.php.cn/zh-tw/faq/1796787760.html" title="Inzoi:如何申請學校和大學" class="phpgenera_Details_mainR4_bottom_title">Inzoi:如何申請學校和大學</a> <div class="phpgenera_Details_mainR4_bottoms_info"> <span>3 週前</span> <span>By DDD</span> </div> </div> <div class="phpgenera_Details_mainR4_bottoms"> <a href="https://www.php.cn/zh-tw/faq/1796793871.html" title="如何修復KB5055518無法在Windows 10中安裝?" class="phpgenera_Details_mainR4_bottom_title">如何修復KB5055518無法在Windows 10中安裝?</a> <div class="phpgenera_Details_mainR4_bottoms_info"> <span>2 週前</span> <span>By DDD</span> </div> </div> <div class="phpgenera_Details_mainR4_bottoms"> <a href="https://www.php.cn/zh-tw/faq/1796786383.html" title="Roblox:Dead Rails - 如何召喚和擊敗Nikola Tesla" class="phpgenera_Details_mainR4_bottom_title">Roblox:Dead Rails - 如何召喚和擊敗Nikola Tesla</a> <div class="phpgenera_Details_mainR4_bottoms_info"> <span>4 週前</span> <span>By 尊渡假赌尊渡假赌尊渡假赌</span> </div> </div> </div> <div class="phpgenera_Details_mainR3_more"> <a href="https://www.php.cn/zh-tw/article.html">顯示更多</a> </div> </div> </div> --> <div class="phpgenera_Details_mainR3"> <div class="phpmain1_4R_readrank"> <div class="phpmain1_4R_readrank_top"> <img onerror="this.onerror=''; this.src='/static/imghw/default1.png'" onerror="this.onerror=''; this.src='/static/imghw/default1.png'" src="/static/imghw/hottools2.png" alt="" /> <h2>熱AI工具</h2> </div> <div class="phpgenera_Details_mainR3_bottom"> <div class="phpmain_tab2_mids_top"> <a href="https://www.php.cn/zh-tw/ai/undresserai-undress" title="Undresser.AI Undress" class="phpmain_tab2_mids_top_img"> <img onerror="this.onerror=''; this.src='/static/imghw/default1.png'" onerror="this.onerror=''; this.src='/static/imghw/default1.png'" class="lazy" data-src="https://img.php.cn/upload/ai_manual/001/246/273/173411540686492.jpg?x-oss-process=image/resize,m_fill,h_50,w_50" src="/static/imghw/default1.png" alt="Undresser.AI Undress" /> </a> <div class="phpmain_tab2_mids_info"> <a href="https://www.php.cn/zh-tw/ai/undresserai-undress" title="Undresser.AI Undress" class="phpmain_tab2_mids_title"> <h3>Undresser.AI Undress</h3> </a> <p>人工智慧驅動的應用程序,用於創建逼真的裸體照片</p> </div> </div> <div class="phpmain_tab2_mids_top"> <a href="https://www.php.cn/zh-tw/ai/ai-clothes-remover" title="AI Clothes Remover" class="phpmain_tab2_mids_top_img"> <img onerror="this.onerror=''; this.src='/static/imghw/default1.png'" onerror="this.onerror=''; this.src='/static/imghw/default1.png'" class="lazy" data-src="https://img.php.cn/upload/ai_manual/001/246/273/173411552797167.jpg?x-oss-process=image/resize,m_fill,h_50,w_50" src="/static/imghw/default1.png" alt="AI Clothes Remover" /> </a> <div class="phpmain_tab2_mids_info"> <a href="https://www.php.cn/zh-tw/ai/ai-clothes-remover" title="AI Clothes Remover" class="phpmain_tab2_mids_title"> <h3>AI Clothes Remover</h3> </a> <p>用於從照片中去除衣服的線上人工智慧工具。</p> </div> </div> <div class="phpmain_tab2_mids_top"> <a href="https://www.php.cn/zh-tw/ai/undress-ai-tool" title="Undress AI Tool" class="phpmain_tab2_mids_top_img"> <img onerror="this.onerror=''; this.src='/static/imghw/default1.png'" onerror="this.onerror=''; this.src='/static/imghw/default1.png'" class="lazy" data-src="https://img.php.cn/upload/ai_manual/001/246/273/173410641626608.jpg?x-oss-process=image/resize,m_fill,h_50,w_50" src="/static/imghw/default1.png" alt="Undress AI Tool" /> </a> <div class="phpmain_tab2_mids_info"> <a href="https://www.php.cn/zh-tw/ai/undress-ai-tool" title="Undress AI Tool" class="phpmain_tab2_mids_title"> <h3>Undress AI Tool</h3> </a> <p>免費脫衣圖片</p> </div> </div> <div class="phpmain_tab2_mids_top"> <a href="https://www.php.cn/zh-tw/ai/clothoffio" title="Clothoff.io" class="phpmain_tab2_mids_top_img"> <img onerror="this.onerror=''; this.src='/static/imghw/default1.png'" onerror="this.onerror=''; this.src='/static/imghw/default1.png'" class="lazy" data-src="https://img.php.cn/upload/ai_manual/001/246/273/173411529149311.jpg?x-oss-process=image/resize,m_fill,h_50,w_50" src="/static/imghw/default1.png" alt="Clothoff.io" /> </a> <div class="phpmain_tab2_mids_info"> <a href="https://www.php.cn/zh-tw/ai/clothoffio" title="Clothoff.io" class="phpmain_tab2_mids_title"> <h3>Clothoff.io</h3> </a> <p>AI脫衣器</p> </div> </div> <div class="phpmain_tab2_mids_top"> <a href="https://www.php.cn/zh-tw/ai/video-swap" title="Video Face Swap" class="phpmain_tab2_mids_top_img"> <img onerror="this.onerror=''; this.src='/static/imghw/default1.png'" onerror="this.onerror=''; this.src='/static/imghw/default1.png'" class="lazy" data-src="https://img.php.cn/upload/ai_manual/001/246/273/173414504068133.jpg?x-oss-process=image/resize,m_fill,h_50,w_50" src="/static/imghw/default1.png" alt="Video Face Swap" /> </a> <div class="phpmain_tab2_mids_info"> <a href="https://www.php.cn/zh-tw/ai/video-swap" title="Video Face Swap" class="phpmain_tab2_mids_title"> <h3>Video Face Swap</h3> </a> <p>使用我們完全免費的人工智慧換臉工具,輕鬆在任何影片中換臉!</p> </div> </div> </div> <div class="phpgenera_Details_mainR3_more"> <a href="https://www.php.cn/zh-tw/ai">顯示更多</a> </div> </div> </div> <script src="https://sw.php.cn/hezuo/cac1399ab368127f9b113b14eb3316d0.js" type="text/javascript"></script> <div class="phpgenera_Details_mainR4"> <div class="phpmain1_4R_readrank"> <div class="phpmain1_4R_readrank_top"> <img onerror="this.onerror=''; this.src='/static/imghw/default1.png'" onerror="this.onerror=''; this.src='/static/imghw/default1.png'" src="/static/imghw/hotarticle2.png" alt="" /> <h2>熱門文章</h2> </div> <div class="phpgenera_Details_mainR4_bottom"> <div class="phpgenera_Details_mainR4_bottoms"> <a href="https://www.php.cn/zh-tw/faq/1796789525.html" title="Windows 11 KB5054979中的新功能以及如何解決更新問題" class="phpgenera_Details_mainR4_bottom_title">Windows 11 KB5054979中的新功能以及如何解決更新問題</a> <div class="phpgenera_Details_mainR4_bottoms_info"> <span>3 週前</span> <span>By DDD</span> </div> </div> <div class="phpgenera_Details_mainR4_bottoms"> <a href="https://www.php.cn/zh-tw/faq/1796793874.html" title="如何修復KB5055523無法在Windows 11中安裝?" class="phpgenera_Details_mainR4_bottom_title">如何修復KB5055523無法在Windows 11中安裝?</a> <div class="phpgenera_Details_mainR4_bottoms_info"> <span>2 週前</span> <span>By DDD</span> </div> </div> <div class="phpgenera_Details_mainR4_bottoms"> <a href="https://www.php.cn/zh-tw/faq/1796787760.html" title="Inzoi:如何申請學校和大學" class="phpgenera_Details_mainR4_bottom_title">Inzoi:如何申請學校和大學</a> <div class="phpgenera_Details_mainR4_bottoms_info"> <span>3 週前</span> <span>By DDD</span> </div> </div> <div class="phpgenera_Details_mainR4_bottoms"> <a href="https://www.php.cn/zh-tw/faq/1796793871.html" title="如何修復KB5055518無法在Windows 10中安裝?" class="phpgenera_Details_mainR4_bottom_title">如何修復KB5055518無法在Windows 10中安裝?</a> <div class="phpgenera_Details_mainR4_bottoms_info"> <span>2 週前</span> <span>By DDD</span> </div> </div> <div class="phpgenera_Details_mainR4_bottoms"> <a href="https://www.php.cn/zh-tw/faq/1796786383.html" title="Roblox:Dead Rails - 如何召喚和擊敗Nikola Tesla" class="phpgenera_Details_mainR4_bottom_title">Roblox:Dead Rails - 如何召喚和擊敗Nikola Tesla</a> <div class="phpgenera_Details_mainR4_bottoms_info"> <span>4 週前</span> <span>By 尊渡假赌尊渡假赌尊渡假赌</span> </div> </div> </div> <div class="phpgenera_Details_mainR3_more"> <a href="https://www.php.cn/zh-tw/article.html">顯示更多</a> </div> </div> </div> <div class="phpgenera_Details_mainR3"> <div class="phpmain1_4R_readrank"> <div class="phpmain1_4R_readrank_top"> <img onerror="this.onerror=''; this.src='/static/imghw/default1.png'" onerror="this.onerror=''; this.src='/static/imghw/default1.png'" src="/static/imghw/hottools2.png" alt="" /> <h2>熱工具</h2> </div> <div class="phpgenera_Details_mainR3_bottom"> <div class="phpmain_tab2_mids_top"> <a href="https://www.php.cn/zh-tw/toolset/development-tools/92" title="記事本++7.3.1" class="phpmain_tab2_mids_top_img"> <img onerror="this.onerror=''; this.src='/static/imghw/default1.png'" onerror="this.onerror=''; this.src='/static/imghw/default1.png'" class="lazy" data-src="https://img.php.cn/upload/manual/000/000/001/58ab96f0f39f7357.jpg?x-oss-process=image/resize,m_fill,h_50,w_72" src="/static/imghw/default1.png" alt="記事本++7.3.1" /> </a> <div class="phpmain_tab2_mids_info"> <a href="https://www.php.cn/zh-tw/toolset/development-tools/92" title="記事本++7.3.1" class="phpmain_tab2_mids_title"> <h3>記事本++7.3.1</h3> </a> <p>好用且免費的程式碼編輯器</p> </div> </div> <div class="phpmain_tab2_mids_top"> <a href="https://www.php.cn/zh-tw/toolset/development-tools/93" title="SublimeText3漢化版" class="phpmain_tab2_mids_top_img"> <img onerror="this.onerror=''; this.src='/static/imghw/default1.png'" onerror="this.onerror=''; this.src='/static/imghw/default1.png'" class="lazy" data-src="https://img.php.cn/upload/manual/000/000/001/58ab97a3baad9677.jpg?x-oss-process=image/resize,m_fill,h_50,w_72" src="/static/imghw/default1.png" alt="SublimeText3漢化版" /> </a> <div class="phpmain_tab2_mids_info"> <a href="https://www.php.cn/zh-tw/toolset/development-tools/93" title="SublimeText3漢化版" class="phpmain_tab2_mids_title"> <h3>SublimeText3漢化版</h3> </a> <p>中文版,非常好用</p> </div> </div> <div class="phpmain_tab2_mids_top"> <a href="https://www.php.cn/zh-tw/toolset/development-tools/121" title="禪工作室 13.0.1" class="phpmain_tab2_mids_top_img"> <img onerror="this.onerror=''; this.src='/static/imghw/default1.png'" onerror="this.onerror=''; this.src='/static/imghw/default1.png'" class="lazy" data-src="https://img.php.cn/upload/manual/000/000/001/58ab97ecd1ab2670.jpg?x-oss-process=image/resize,m_fill,h_50,w_72" src="/static/imghw/default1.png" alt="禪工作室 13.0.1" /> </a> <div class="phpmain_tab2_mids_info"> <a href="https://www.php.cn/zh-tw/toolset/development-tools/121" title="禪工作室 13.0.1" class="phpmain_tab2_mids_title"> <h3>禪工作室 13.0.1</h3> </a> <p>強大的PHP整合開發環境</p> </div> </div> <div class="phpmain_tab2_mids_top"> <a href="https://www.php.cn/zh-tw/toolset/development-tools/469" title="Dreamweaver CS6" class="phpmain_tab2_mids_top_img"> <img onerror="this.onerror=''; this.src='/static/imghw/default1.png'" onerror="this.onerror=''; this.src='/static/imghw/default1.png'" class="lazy" data-src="https://img.php.cn/upload/manual/000/000/001/58d0e0fc74683535.jpg?x-oss-process=image/resize,m_fill,h_50,w_72" src="/static/imghw/default1.png" alt="Dreamweaver CS6" /> </a> <div class="phpmain_tab2_mids_info"> <a href="https://www.php.cn/zh-tw/toolset/development-tools/469" title="Dreamweaver CS6" class="phpmain_tab2_mids_title"> <h3>Dreamweaver CS6</h3> </a> <p>視覺化網頁開發工具</p> </div> </div> <div class="phpmain_tab2_mids_top"> <a href="https://www.php.cn/zh-tw/toolset/development-tools/500" title="SublimeText3 Mac版" class="phpmain_tab2_mids_top_img"> <img onerror="this.onerror=''; this.src='/static/imghw/default1.png'" onerror="this.onerror=''; this.src='/static/imghw/default1.png'" class="lazy" data-src="https://img.php.cn/upload/manual/000/000/001/58d34035e2757995.png?x-oss-process=image/resize,m_fill,h_50,w_72" src="/static/imghw/default1.png" alt="SublimeText3 Mac版" /> </a> <div class="phpmain_tab2_mids_info"> <a href="https://www.php.cn/zh-tw/toolset/development-tools/500" title="SublimeText3 Mac版" class="phpmain_tab2_mids_title"> <h3>SublimeText3 Mac版</h3> </a> <p>神級程式碼編輯軟體(SublimeText3)</p> </div> </div> </div> <div class="phpgenera_Details_mainR3_more"> <a href="https://www.php.cn/zh-tw/ai">顯示更多</a> </div> </div> </div> <div class="phpgenera_Details_mainR4"> <div class="phpmain1_4R_readrank"> <div class="phpmain1_4R_readrank_top"> <img onerror="this.onerror=''; this.src='/static/imghw/default1.png'" onerror="this.onerror=''; this.src='/static/imghw/default1.png'" src="/static/imghw/hotarticle2.png" alt="" /> <h2>熱門話題</h2> </div> <div class="phpgenera_Details_mainR4_bottom"> <div class="phpgenera_Details_mainR4_bottoms"> <a href="https://www.php.cn/zh-tw/faq/gmailyxdlrkzn" title="gmail信箱登陸入口在哪裡" class="phpgenera_Details_mainR4_bottom_title">gmail信箱登陸入口在哪裡</a> <div class="phpgenera_Details_mainR4_bottoms_info"> <div class="phpgenera_Details_mainR4_bottoms_infos"> <img src="/static/imghw/eyess.png" alt="" /> <span>7807</span> </div> <div class="phpgenera_Details_mainR4_bottoms_infos"> <img src="/static/imghw/tiezi.png" alt="" /> <span>15</span> </div> </div> </div> <div class="phpgenera_Details_mainR4_bottoms"> <a href="https://www.php.cn/zh-tw/faq/java-tutorial" title="Java教學" class="phpgenera_Details_mainR4_bottom_title">Java教學</a> <div class="phpgenera_Details_mainR4_bottoms_info"> <div class="phpgenera_Details_mainR4_bottoms_infos"> <img src="/static/imghw/eyess.png" alt="" /> <span>1646</span> </div> <div class="phpgenera_Details_mainR4_bottoms_infos"> <img src="/static/imghw/tiezi.png" alt="" /> <span>14</span> </div> </div> </div> <div class="phpgenera_Details_mainR4_bottoms"> <a href="https://www.php.cn/zh-tw/faq/cakephp-tutor" title="CakePHP 教程" class="phpgenera_Details_mainR4_bottom_title">CakePHP 教程</a> <div class="phpgenera_Details_mainR4_bottoms_info"> <div class="phpgenera_Details_mainR4_bottoms_infos"> <img src="/static/imghw/eyess.png" alt="" /> <span>1402</span> </div> <div class="phpgenera_Details_mainR4_bottoms_infos"> <img src="/static/imghw/tiezi.png" alt="" /> <span>52</span> </div> </div> </div> <div class="phpgenera_Details_mainR4_bottoms"> <a href="https://www.php.cn/zh-tw/faq/laravel-tutori" title="Laravel 教程" class="phpgenera_Details_mainR4_bottom_title">Laravel 教程</a> <div class="phpgenera_Details_mainR4_bottoms_info"> <div class="phpgenera_Details_mainR4_bottoms_infos"> <img src="/static/imghw/eyess.png" alt="" /> <span>1300</span> </div> <div class="phpgenera_Details_mainR4_bottoms_infos"> <img src="/static/imghw/tiezi.png" alt="" /> <span>25</span> </div> </div> </div> <div class="phpgenera_Details_mainR4_bottoms"> <a href="https://www.php.cn/zh-tw/faq/php-tutorial" title="PHP教程" class="phpgenera_Details_mainR4_bottom_title">PHP教程</a> <div class="phpgenera_Details_mainR4_bottoms_info"> <div class="phpgenera_Details_mainR4_bottoms_infos"> <img src="/static/imghw/eyess.png" alt="" /> <span>1236</span> </div> <div class="phpgenera_Details_mainR4_bottoms_infos"> <img src="/static/imghw/tiezi.png" alt="" /> <span>29</span> </div> </div> </div> </div> <div class="phpgenera_Details_mainR3_more"> <a href="https://www.php.cn/zh-tw/faq/zt">顯示更多</a> </div> </div> </div> </div> </div> <div class="Article_Details_main2"> <div class="phpgenera_Details_mainL4"> <div class="phpmain1_2_top"> <a href="javascript:void(0);" class="phpmain1_2_top_title">Related knowledge<img src="/static/imghw/index2_title2.png" alt="" /></a> </div> <div class="phpgenera_Details_mainL4_info"> <div class="phphistorical_Version2_mids"> <a href="https://www.php.cn/zh-tw/faq/1796799180.html" title="wordpress文章列表怎麼調" class="phphistorical_Version2_mids_img"> <img onerror="this.onerror=''; this.src='/static/imghw/default1.png'" src="/static/imghw/default1.png" class="lazy" data-src="https://img.php.cn/upload/article/202406/05/2024060502302364469.jpg?x-oss-process=image/resize,m_fill,h_207,w_330" alt="wordpress文章列表怎麼調" /> </a> <a href="https://www.php.cn/zh-tw/faq/1796799180.html" title="wordpress文章列表怎麼調" class="phphistorical_Version2_mids_title">wordpress文章列表怎麼調</a> <span class="Articlelist_txts_time">Apr 20, 2025 am 10:48 AM</span> <p class="Articlelist_txts_p">有四種方法可以調整 WordPress 文章列表:使用主題選項、使用插件(如 Post Types Order、WP Post List、Boxy Stuff)、使用代碼(在 functions.php 文件中添加設置)或直接修改 WordPress 數據庫。</p> </div> <div class="phphistorical_Version2_mids"> <a href="https://www.php.cn/zh-tw/faq/1796799007.html" title="wordpress屏蔽ip的插件有哪些" class="phphistorical_Version2_mids_img"> <img onerror="this.onerror=''; this.src='/static/imghw/default1.png'" src="/static/imghw/default1.png" class="lazy" data-src="https://img.php.cn/upload/article/202412/20/2024122016271915108.jpg?x-oss-process=image/resize,m_fill,h_207,w_330" alt="wordpress屏蔽ip的插件有哪些" /> </a> <a href="https://www.php.cn/zh-tw/faq/1796799007.html" title="wordpress屏蔽ip的插件有哪些" class="phphistorical_Version2_mids_title">wordpress屏蔽ip的插件有哪些</a> <span class="Articlelist_txts_time">Apr 20, 2025 am 08:27 AM</span> <p class="Articlelist_txts_p">WordPress 屏蔽 IP 的插件選擇至關重要。可考慮以下類型:基於 .htaccess:高效,但操作複雜;數據庫操作:靈活,但效率較低;基於防火牆:安全性能高,但配置複雜;自行編寫:最高控制權,但需要更多技術水平。</p> </div> <div class="phphistorical_Version2_mids"> <a href="https://www.php.cn/zh-tw/faq/1796799191.html" title="wordpress編輯日期怎麼取消" class="phphistorical_Version2_mids_img"> <img onerror="this.onerror=''; this.src='/static/imghw/default1.png'" src="/static/imghw/default1.png" class="lazy" data-src="https://img.php.cn/upload/article/202406/05/2024060502241780858.jpg?x-oss-process=image/resize,m_fill,h_207,w_330" alt="wordpress編輯日期怎麼取消" /> </a> <a href="https://www.php.cn/zh-tw/faq/1796799191.html" title="wordpress編輯日期怎麼取消" class="phphistorical_Version2_mids_title">wordpress編輯日期怎麼取消</a> <span class="Articlelist_txts_time">Apr 20, 2025 am 10:54 AM</span> <p class="Articlelist_txts_p">WordPress 編輯日期可以通過三種方法取消:1. 安裝 Enable Post Date Disable 插件;2. 在 functions.php 文件中添加代碼;3. 手動編輯 wp_posts 表中的 post_modified 列。</p> </div> <div class="phphistorical_Version2_mids"> <a href="https://www.php.cn/zh-tw/faq/1796799266.html" title="wordpress怎麼寫頁頭" class="phphistorical_Version2_mids_img"> <img onerror="this.onerror=''; this.src='/static/imghw/default1.png'" src="/static/imghw/default1.png" class="lazy" data-src="https://img.php.cn/upload/article/202406/05/2024060501032186680.jpg?x-oss-process=image/resize,m_fill,h_207,w_330" alt="wordpress怎麼寫頁頭" /> </a> <a href="https://www.php.cn/zh-tw/faq/1796799266.html" title="wordpress怎麼寫頁頭" class="phphistorical_Version2_mids_title">wordpress怎麼寫頁頭</a> <span class="Articlelist_txts_time">Apr 20, 2025 pm 12:09 PM</span> <p class="Articlelist_txts_p">在WordPress中創建自定義頁頭的步驟如下:編輯主題文件“header.php”。添加您的網站名稱和描述。創建導航菜單。添加搜索欄。保存更改並查看您的自定義頁頭。</p> </div> <div class="phphistorical_Version2_mids"> <a href="https://www.php.cn/zh-tw/faq/1796799094.html" title="wordpress主題頭部圖片如何更換" class="phphistorical_Version2_mids_img"> <img onerror="this.onerror=''; this.src='/static/imghw/default1.png'" src="/static/imghw/default1.png" class="lazy" data-src="https://img.php.cn/upload/article/202406/05/2024060503302282499.jpg?x-oss-process=image/resize,m_fill,h_207,w_330" alt="wordpress主題頭部圖片如何更換" /> </a> <a href="https://www.php.cn/zh-tw/faq/1796799094.html" title="wordpress主題頭部圖片如何更換" class="phphistorical_Version2_mids_title">wordpress主題頭部圖片如何更換</a> <span class="Articlelist_txts_time">Apr 20, 2025 am 10:00 AM</span> <p class="Articlelist_txts_p">更換 WordPress 主題頭部圖片的分步指南:登錄 WordPress 儀錶盤,導航至“外觀”&gt;“主題”。選擇要編輯的主題,然後單擊“自定義”。打開“主題選項”面板並尋找“網站標頭”或“頭部圖片”選項。單擊“選擇圖像”按鈕並上傳新的頭部圖片。裁剪圖像並單擊“保存並裁剪”。單擊“保存並發布”按鈕以更新更改。</p> </div> <div class="phphistorical_Version2_mids"> <a href="https://www.php.cn/zh-tw/faq/1796799214.html" title="wordpress主機怎麼建站" class="phphistorical_Version2_mids_img"> <img onerror="this.onerror=''; this.src='/static/imghw/default1.png'" src="/static/imghw/default1.png" class="lazy" data-src="https://img.php.cn/upload/article/202406/05/2024060502062141595.jpg?x-oss-process=image/resize,m_fill,h_207,w_330" alt="wordpress主機怎麼建站" /> </a> <a href="https://www.php.cn/zh-tw/faq/1796799214.html" title="wordpress主機怎麼建站" class="phphistorical_Version2_mids_title">wordpress主機怎麼建站</a> <span class="Articlelist_txts_time">Apr 20, 2025 am 11:12 AM</span> <p class="Articlelist_txts_p">要使用 WordPress 主機建站,需要:選擇一個可靠的主機提供商。購買一個域名。設置 WordPress 主機帳戶。選擇一個主題。添加頁面和文章。安裝插件。自定義您的網站。發布您的網站。</p> </div> <div class="phphistorical_Version2_mids"> <a href="https://www.php.cn/zh-tw/faq/1796799259.html" title="wordpress出現錯誤怎麼辦" class="phphistorical_Version2_mids_img"> <img onerror="this.onerror=''; this.src='/static/imghw/default1.png'" src="/static/imghw/default1.png" class="lazy" data-src="https://img.php.cn/upload/article/202406/05/2024060501182096513.jpg?x-oss-process=image/resize,m_fill,h_207,w_330" alt="wordpress出現錯誤怎麼辦" /> </a> <a href="https://www.php.cn/zh-tw/faq/1796799259.html" title="wordpress出現錯誤怎麼辦" class="phphistorical_Version2_mids_title">wordpress出現錯誤怎麼辦</a> <span class="Articlelist_txts_time">Apr 20, 2025 am 11:57 AM</span> <p class="Articlelist_txts_p">WordPress 錯誤解決指南:500 內部服務器錯誤:禁用插件或檢查服務器錯誤日誌。 404 未找到頁面:檢查 permalink 並確保頁面鏈接正確。白屏死機:增加服務器 PHP 內存限制。數據庫連接錯誤:檢查數據庫服務器狀態和 WordPress 配置。其他技巧:啟用調試模式、檢查錯誤日誌和尋求支持。預防錯誤:定期更新 WordPress、僅安裝必要插件、定期備份網站和優化網站性能。</p> </div> <div class="phphistorical_Version2_mids"> <a href="https://www.php.cn/zh-tw/faq/1796799264.html" title="wordpress評論怎麼顯示" class="phphistorical_Version2_mids_img"> <img onerror="this.onerror=''; this.src='/static/imghw/default1.png'" src="/static/imghw/default1.png" class="lazy" data-src="https://img.php.cn/upload/article/202406/05/2024060501062082871.jpg?x-oss-process=image/resize,m_fill,h_207,w_330" alt="wordpress評論怎麼顯示" /> </a> <a href="https://www.php.cn/zh-tw/faq/1796799264.html" title="wordpress評論怎麼顯示" class="phphistorical_Version2_mids_title">wordpress評論怎麼顯示</a> <span class="Articlelist_txts_time">Apr 20, 2025 pm 12:06 PM</span> <p class="Articlelist_txts_p">WordPress 網站中啟用評論功能:1. 登錄管理面板,轉到 "設置"-"討論",勾選 "允許評論";2. 選擇顯示評論的位置;3. 自定義評論表單;4. 管理評論,批准、拒絕或刪除;5. 使用 &lt;?php comments_template(); ?&gt; 標籤顯示評論;6. 啟用嵌套評論;7. 調整評論外形;8. 使用插件和驗證碼防止垃圾評論;9. 鼓勵用戶使用 Gravatar 頭像;10. 創建評論指</p> </div> </div> <a href="https://www.php.cn/zh-tw/cms/" class="phpgenera_Details_mainL4_botton"> <span>See all articles</span> <img src="/static/imghw/down_right.png" alt="" /> </a> </div> </div> </div> </main> <footer> <div class="footer"> <div class="footertop"> <img src="/static/imghw/logo.png" alt=""> <p>公益線上PHP培訓,幫助PHP學習者快速成長!</p> </div> <div class="footermid"> <a href="https://www.php.cn/zh-tw/about/us.html">關於我們</a> <a href="https://www.php.cn/zh-tw/about/disclaimer.html">免責聲明</a> <a href="https://www.php.cn/zh-tw/update/article_0_1.html">Sitemap</a> </div> <div class="footerbottom"> <p> © php.cn All rights reserved </p> </div> </div> </footer> <input type="hidden" id="verifycode" value="/captcha.html"> <script>layui.use(['element', 'carousel'], function () {var element = layui.element;$ = layui.jquery;var carousel = layui.carousel;carousel.render({elem: '#test1', width: '100%', height: '330px', arrow: 'always'});$.getScript('/static/js/jquery.lazyload.min.js', function () {$("img").lazyload({placeholder: "/static/images/load.jpg", effect: "fadeIn", threshold: 200, skip_invisible: false});});});</script> <script src="/static/js/common_new.js"></script> <script type="text/javascript" src="/static/js/jquery.cookie.js?1745886330"></script> <script src="https://vdse.bdstatic.com//search-video.v1.min.js"></script> <link rel='stylesheet' id='_main-css' href='/static/css/viewer.min.css?2' type='text/css' media='all' /> <script type='text/javascript' src='/static/js/viewer.min.js?1'></script> <script type='text/javascript' src='/static/js/jquery-viewer.min.js'></script> <script type="text/javascript" src="/static/js/global.min.js?5.5.53"></script> <script> var _paq = window._paq = window._paq || []; /* tracker methods like "setCustomDimension" should be called before "trackPageView" */ _paq.push(['trackPageView']); _paq.push(['enableLinkTracking']); (function () { var u = "https://tongji.php.cn/"; _paq.push(['setTrackerUrl', u + 'matomo.php']); _paq.push(['setSiteId', '9']); var d = document, g = d.createElement('script'), s = d.getElementsByTagName('script')[0]; g.async = true; g.src = u + 'matomo.js'; s.parentNode.insertBefore(g, s); })(); </script> <script> // top layui.use(function () { var util = layui.util; util.fixbar({ on: { mouseenter: function (type) { layer.tips(type, this, { tips: 4, fixed: true, }); }, mouseleave: function (type) { layer.closeAll("tips"); }, }, }); }); document.addEventListener("DOMContentLoaded", (event) => { // 定义一个函数来处理滚动链接的点击事件 function setupScrollLink(scrollLinkId, targetElementId) { const scrollLink = document.getElementById(scrollLinkId); const targetElement = document.getElementById(targetElementId); if (scrollLink && targetElement) { scrollLink.addEventListener("click", (e) => { e.preventDefault(); // 阻止默认链接行为 targetElement.scrollIntoView({ behavior: "smooth" }); // 平滑滚动到目标元素 }); } else { console.warn( `Either scroll link with ID '${scrollLinkId}' or target element with ID '${targetElementId}' not found.` ); } } // 使用该函数设置多个滚动链接 setupScrollLink("Article_Details_main1L2s_1", "article_main_title1"); setupScrollLink("Article_Details_main1L2s_2", "article_main_title2"); setupScrollLink("Article_Details_main1L2s_3", "article_main_title3"); setupScrollLink("Article_Details_main1L2s_4", "article_main_title4"); setupScrollLink("Article_Details_main1L2s_5", "article_main_title5"); setupScrollLink("Article_Details_main1L2s_6", "article_main_title6"); // 可以继续添加更多的滚动链接设置 }); window.addEventListener("scroll", function () { var fixedElement = document.getElementById("Article_Details_main1Lmain"); var scrollTop = window.scrollY || document.documentElement.scrollTop; // 兼容不同浏览器 var clientHeight = window.innerHeight || document.documentElement.clientHeight; // 视口高度 var scrollHeight = document.documentElement.scrollHeight; // 页面总高度 // 计算距离底部的距离 var distanceToBottom = scrollHeight - scrollTop - clientHeight; // 当距离底部小于或等于300px时,取消固定定位 if (distanceToBottom <= 980) { fixedElement.classList.remove("Article_Details_main1Lmain"); fixedElement.classList.add("Article_Details_main1Lmain_relative"); } else { // 否则,保持固定定位 fixedElement.classList.remove("Article_Details_main1Lmain_relative"); fixedElement.classList.add("Article_Details_main1Lmain"); } }); </script> <script> document.addEventListener('DOMContentLoaded', function() { const mainNav = document.querySelector('.Article_Details_main1Lmain'); const header = document.querySelector('header'); if (mainNav) { window.addEventListener('scroll', function() { const scrollPosition = window.scrollY; if (scrollPosition > 84) { mainNav.classList.add('fixed'); } else { mainNav.classList.remove('fixed'); } }); } }); </script> </body> </html>