名言簿丨mottobook
相信文字的力量!名人名言,经典语录,深度好文,哲理故事,寓言,格言,箴言,座右铭精选,文字的光辉,犹如黑夜的明星,海上的灯塔,指引前行的方向,在潜移默化中打开格局,提升自我,成就人生!

wordpress长篇文章分页显示代码

在functions.php文件里加入如下代码:

add_filter( 'mce_buttons', 'cmp_add_page_break_button', 1, 2 );
 
function cmp_add_page_break_button( $buttons, $id )
 
{ if ( 'content' != $id ) return $buttons;
 
array_splice( $buttons, 13, 0, 'wp_page' ); return $buttons; }

这样就实现了编辑框显示分页按钮。接下来是美化步骤:

1.在single.php 中的<?php the_content(); ?>后面加上如下代码(如有<?php wp_link_pages(); ?>用下面的代码替换):

<?php wp_link_pages(array('before' => '<div class="fenye">', 'after' => '', 'next_or_number' => 'next', 'previouspagelink' => '<span>上一页</span>', 'nextpagelink' => "")); ?>
<?php wp_link_pages(array('before' => '', 'after' => '', 'next_or_number' => 'number', 'link_before' =>'<span>', 'link_after'=>'</span>')); ?>
<?php wp_link_pages(array('before' => '', 'after' => '</div>', 'next_or_number' => 'next', 'previouspagelink' => '', 'nextpagelink' => "<span>下一页</span>")); ?>

2.为分页按钮添加css:本站为例

.fenye{text-align: center;margin: 0px 10px;padding-right:20px;font-size: 16px;line-height: 50px;}
 
.fenye span{background:#20B2AA; color: #fff; margin: 2px; line-height: 30px; cursor: pointer; padding: 0 10px; display: inline-block; border: 1px solid #20B2AA; border-radius: 3px;}

.fenye a{text-decoration:none;}
 
.fenye a span{background-color:	#F0FFFF;font-weight: normal;color: #000;text-decoration: none;}
 
.fenye a span:hover{background-color:DarkTurquoise;border:1px solid DarkTurquoise;color: #fff;}
Scroll Up