我正在尝试对显示在术语存档中的自定义模板进行分页。
它似乎正在工作,因为当我导航到mysite/taxonomy/page/2/
或3、4、5等。分页工作。它还显示每页正确的术语数。然而,在我的页面底部并没有显示任何实际的分页链接,听起来应该有。
我正在跟踪this tutorial 以及Codex instructions, 但我肯定错过了什么。有人能帮我弄清楚是什么吗?下面是我的简化代码。
<?php get_header(); ?>
<div class="container">
<div class="row">
<div class="col-md-12">
<div class="row">
<div class="col-md-9">
<h2>Index Post Type Archive </h2>
<hr/>
<!-- Begin LG Screen View-->
<span class="visible-lg">
<article>
<div class="row">
<?php
if ( get_query_var( \'paged\' ) )
$paged = get_query_var(\'paged\');
else if ( get_query_var( \'page\' ) )
$paged = get_query_var( \'page\' );
else
$paged = 1;
$per_page = 12;
$number_of_terms = count( get_terms( \'100list\' ) ); // This counts the total number terms in the taxonomy with a function)
$offset = $per_page * ( $paged - 1) ;
$libargs=array(
\'orderby\' => \'name\',
\'order\' => \'ASC\',
\'hide_empty\' => 0,
\'exclude\' => array(16, 20, 22,25, 27, 28, 30, 4, 42, 7, 43 ), //* Enter ID\'s of parent categories to exclude from list
\'taxonomy\' => \'100list\',
\'parent\' => \'\',
\'number\' => $per_page,
\'offset\' => $offset,
);
$libcats=get_categories($libargs);
$i = 0;
foreach($libcats as $lc){
if( $i % 4 == 0 ) {
echo \'<div class="clearfix"></div>\';
}
$i++;
echo \'<div class="col-lg-3">\';
$termlink = get_term_link( $lc->slug, \'100list\' );
?>
<div class="thumbnail">
<div class="caption">
<br/><br/>
<h1><span class="label label-warning"><?php echo $lc->count ?></span></h1>
<p> Symbols </p>
<p> <a class="label label-default" href="<?php echo $termlink; ?>"> View Group</a> </p>
</div>
<!-- Get Image by Attachment ID Start-->
<?php
$attachment_id = get_field(\'taximage\', \'100list_\'.$lc->term_id);
if ($attachment_id) {
$image = wp_get_attachment_image_src($attachment_id, \'industrygroup-img\');
if ($image) {
?>
<img class="img-responsive" src="<?php echo $image[0]; ?>" />
<?php } }
else { ?>
<img class="img-responsive" src="http://www.runningalpha.com/wp-content/uploads/2014/08/RA_logo_300px_groups.jpg" alt="<?php the_title(); ?>" />
<?php } ?>
<!-- Get Image by Attachment ID End-->
</div>
<small><p class="text-center"> <a href="<?php echo $termlink; ?>"> <?php echo $lc->name; ?></a> </p> </small>
<?php echo \'</div>\'; } ?>
<?php if (function_exists("pagination")) {
$big = 999999999; // need an unlikely integer
echo paginate_links( array(
\'base\' => str_replace( $big, \'%#%\', esc_url( get_pagenum_link( $big ) ) ),
\'format\' => \'/page/%#%\',
\'current\' => $paged,
\'total\' => ceil( $number_of_terms / $per_page ) // 20 items per page
) );
}
?>
</div>
</article>
</span>
</div> <!-- End col-md-9 -->
<div class="col-md-3">
<?php include("sidebar100list.php"); ?>
</div> <!-- End col-md-3 -->
</div><!-- End row -->
</div><!-- End Container -->
<?php get_footer(); ?>