不少WordPress朋友总喜欢给长一点的文章进行分页,但是默认情况下,在WordPress的编辑器中,是没有显示“下一页”按钮的,每次都要手动添加分页代码 <!--nextpage-->是一件非常费力的事,其实,我们只要在当前主题的 functions.php 添加下面的代码,就可以显示“下一页”按钮啦。
<span class="co4">/**</span>
<span class="co4">?* http://www.wpdaxue.com/add-next-page-button-wordpress-post-editor.html</span>
<span class="co4">?*/</span>
add_filter<span class="br0">(</span><span class="st_h">'mce_buttons'</span><span class="sy0">,</span><span class="st_h">'wpdaxue_add_next_page_button'</span><span class="br0">)</span><span class="sy0">;</span>
<span class="kw2">function</span> wpdaxue_add_next_page_button<span class="br0">(</span><span class="re0">$mce_buttons</span><span class="br0">)</span> <span class="br0">{</span>
<span class="re0">$pos</span> <span class="sy0">=</span> <span class="kw3">array_search</span><span class="br0">(</span><span class="st_h">'wp_more'</span><span class="sy0">,</span><span class="re0">$mce_buttons</span><span class="sy0">,</span><span class="kw4">true</span><span class="br0">)</span><span class="sy0">;</span>
<span class="kw1">if</span> <span class="br0">(</span><span class="re0">$pos</span> <span class="sy0">!==</span> <span class="kw4">false</span><span class="br0">)</span> <span class="br0">{</span>
<span class="re0">$tmp_buttons</span> <span class="sy0">=</span> <span class="kw3">array_slice</span><span class="br0">(</span><span class="re0">$mce_buttons</span><span class="sy0">,</span> <span class="nu0">0</span><span class="sy0">,</span> <span class="re0">$pos</span><span class="sy0">+</span><span class="nu0">1</span><span class="br0">)</span><span class="sy0">;</span>
<span class="re0">$tmp_buttons</span><span class="br0">[</span><span class="br0">]</span> <span class="sy0">=</span> <span class="st_h">'wp_page'</span><span class="sy0">;</span>
<span class="re0">$mce_buttons</span> <span class="sy0">=</span> <span class="kw3">array_merge</span><span class="br0">(</span><span class="re0">$tmp_buttons</span><span class="sy0">,</span> <span class="kw3">array_slice</span><span class="br0">(</span><span class="re0">$mce_buttons</span><span class="sy0">,</span> <span class="re0">$pos</span><span class="sy0">+</span><span class="nu0">1</span><span class="br0">)</span><span class="br0">)</span><span class="sy0">;</span>
<span class="br0">}</span>
<span class="kw1">return</span> <span class="re0">$mce_buttons</span><span class="sy0">;</span>
<span class="br0">}</span>
最终效果如下图所示:
文章页面演示地址请浏览 http://www.9frc.com
声明:本文为原创文章,版权归越鹰家博客所有,欢迎分享本文,转载请保留出处!
你可能也喜欢
- ♥ 坚持()是全面推行河长制的支撑点,核心是建立健全河湖管理保护的监督03/15
- ♥ 百度快速收录提交入口04/26
- ♥ 【帅飞了】夏天最适合男人穿的四个颜色07/28
- ♥ 国际足联世界杯多少年举办一次(四年一次)11/19
- ♥ 【咬文嚼字】天方夜谭为何不是“夜谈”10/23
- ♥ 【感悟】有的时候,“二”或许才是最佳选择05/21