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: #2f889a; color: #fff; margin: 2px; line-height: 30px; cursor: pointer; padding: 0 12px; display: inline-block; border: 1px solid #2f889a; border-radius: 2px;} .fenye a{text-decoration:none;}

.fenye a span{background-color:#F6F6E8;font-weight: normal;color: #000;text-decoration: none;}

.fenye a span:hover{background-color:#c73503;border:1px solid #c73503;color: #fff;}


发表评论