Skip to main content
Better readability
Source Link
Pieter Goosen
  • 55.4k
  • 23
  • 115
  • 209

I am trying to achieve pagination on a custom template I have that displays on an archive of terms. 

It appears to be working because when I navigate to mysite/taxonomy/page/2/ or 3,4,5 etc. the pagination works. It also shows the correct number of terms per page. However, there are not any actual pagination links showing on the bottom of my page and it sounds like there is supposed to be. 

I am following this tutorial as well as the Codex instructions, but I have to be missing something. Can someone please help figure out what? My simplified code is below.

I am trying to achieve pagination on a custom template I have that displays an archive of terms. It appears to be working because when I navigate to mysite/taxonomy/page/2/ or 3,4,5 etc. the pagination works. It also shows the correct number of terms per page. However, there are not any actual pagination links showing on the bottom of my page and it sounds like there is supposed to be. I am following this tutorial as well as the Codex instructions, but I have to be missing something. Can someone please help figure out what? My simplified code is below.

I am trying to achieve pagination on a custom template I have that displays on an archive of terms. 

It appears to be working because when I navigate to mysite/taxonomy/page/2/ or 3,4,5 etc. the pagination works. It also shows the correct number of terms per page. However, there are not any actual pagination links showing on the bottom of my page and it sounds like there is supposed to be. 

I am following this tutorial as well as the Codex instructions, but I have to be missing something. Can someone please help figure out what? My simplified code is below.

Source Link
streetfire
  • 266
  • 3
  • 15

Pagination Not Displaying on Custom Term Archive

I am trying to achieve pagination on a custom template I have that displays an archive of terms. It appears to be working because when I navigate to mysite/taxonomy/page/2/ or 3,4,5 etc. the pagination works. It also shows the correct number of terms per page. However, there are not any actual pagination links showing on the bottom of my page and it sounds like there is supposed to be. I am following this tutorial as well as the Codex instructions, but I have to be missing something. Can someone please help figure out what? My simplified code is below.

<?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(); ?>