我有一个分类法列表,我想对此列表进行分页,我尝试了这段代码,但结果和总页数。
我想将此数字限制为5并使导航正常工作。 如本例所示:1 2 3 ... 5 6 7,5 6 7 ... 10 11 12 14
这是我的代码
<?php
if(isset($ _ GET ['showall'])):
$args = array( 'hide_empty' => 0 );
否则:
$page = ( get_query_var('paged') ) ? get_query_var( 'paged' ) : 1;
// number of tags to show per-page
$per_page = 28;
$offset = ( $page-1 ) * $per_page;
$args = array( 'number' => $per_page, 'offset' => $offset, 'hide_empty' => 0 );
ENDIF;
$ taxonomy ='actor'; $ tax_terms = get_terms($ taxonomy,$ args);
echo'';
foreach($ tax_terms as $ tax_term){ 回声''; 回声''。 '名称 ) 。 ''''。'&gt;
echo'';
$total_terms = wp_count_terms( 'actor' );
$pages = ceil($total_terms/$per_page);
// if there's more than one page
if( $pages > 1 ):
echo '<div class="page-nav td-pb-padding-side">';
if ($page > 1) { ?>
<a href="<?php the_permalink(); ?>page/<?php echo $page-1; ?>" class="sermonPaging"><i class="td-icon-menu-left"></i></a>
<?php }
for ($pagecount=1; $pagecount <= $pages; $pagecount++):
echo '<a class="nav-actor" href="'.get_permalink().'page/'.$pagecount.'/">'.$pagecount.'</a>';
endfor;
if ($page < $pages ) { ?>
<a href="<?php the_permalink(); ?>page/<?php echo $page+1; ?>" class="sermonPaging"><i class="td-icon-menu-right"></i></a>
<?php }
echo '<div class="nav-count">';
global $page, $total_terms;
echo "Página $page de $total_terms";
echo '</div>';
echo '</div>';
否则: ENDIF;
&GT;