我当前的功能显示下一页和上一页的页数和按钮数。我的目的是只显示上一个和下一个按钮,但无法编辑此功能。
这是功能代码
function mts_wp_link_pages_args( $args ) {
global $page, $numpages, $more, $pagenow;
if ( !$args['next_or_number'] == 'next_and_number' )
return $args;
$args['next_or_number'] = 'number';
if ( !$more )
return $args;
if( $page-1 )
$args['before'] .= _wp_link_page( $page-1 )
. $args['link_before']. $args['previouspagelink'] . $args['link_after'] . '</a>'
;
if ( $page<$numpages )
$args['after'] = _wp_link_page( $page+1 )
. $args['link_before'] . $args['nextpagelink'] . $args['link_after'] . '</a>'
. $args['after']
;
return $args;
}
add_filter( 'wp_link_pages_args', 'mts_wp_link_pages_args' );
这就是在single.php中调用的内容
<?php wp_link_pages(array('before' => '<div class="pagination">', 'after' => '</div>', 'link_before' => '<span class="current"><span class="currenttext">', 'link_after' => '</span></span>', 'next_or_number' => 'next_and_number', 'nextpagelink' => __('Next','mythemeshop'), 'previouspagelink' => __('Previous','mythemeshop'), 'pagelink' => '%','echo' => 1 )); ?>
任何帮助都会很棒。
答案 0 :(得分:0)
想出来
<?php
global $page, $pages;
wp_link_pages( array( 'before' => '<div style="text-align: center;" class="page-link-next-prev">',
'after' => '', 'previouspagelink' => '<span style="float:left;min-width: 60px;
background-color: #d86043;
-webkit-border-radius: 3px;
-moz-border-radius: 3px;
border-radius: 3px;
padding: 5px 20px;
color: #FFF;" class="meta-item">Previous post</span>', 'nextpagelink' => '',
'next_or_number' => 'next' ) );
echo('<span style="text-align: center;">'.$page.' of '.count($pages).'</span>');
wp_link_pages( array( 'before' => '',
'after' => '</div>',
'previouspagelink' => '',
'nextpagelink' => '<span style="float:right; min-width: 60px;
background-color: #d86043;
-webkit-border-radius: 3px;
-moz-border-radius: 3px;
border-radius: 3px;
padding: 5px 20px;
color: #FFF;" class="meta-item">Next post</span>', 'next_or_number' => 'next' ) );
?>