I've been looking at this problem for a few weeks now, constantly running into the same problem. It's a bit of a complicated setup:

I've got a category called "dossiers". I've also got a custom taxonomy "dossiers" which is used to group posts that are about the same news event or story. When someone creates a post, they can assign the post to certain dossier and then put it in the category for "dossiers". That way, all dossier-posts are filed under the same category while still having a way to separate stories from each other.

I need the category page for the category "dossiers" to display all the custom taxonomy terms in the taxonomy "dossiers". These, in turn, link to their own listing of that particular dossier. I created the category-dossiers.php file which replaces the default category page, so that's not a problem anymore.

Using other forum posts, particular this one, I have gotten the bulk of the problem figured out. The category-page shows all taxonomy terms, with links and everything, and can split them up into pages. (This is a bit hacky because WordPress normally doesn't use terms as the main content blocks, but posts).

My only problem right now is to get the second, third, etc. page working. Beyond the first page it just displays the default index.php file of my theme.

Here is the full template page. Can anyone figure out what's wrong with it? I've tried and tried but just can't seem to find the problem.

<?php get_header(); ?>

<?php get_sidebar (); ?>

<section class="articles grid main-content category">
    <header class="grid-header">
            <h2><?php single_cat_title();?></h2>

            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    = 9;
            $number_of_terms = count( get_terms( "dossiers") );
            $offset      = $per_page * ( $paged - 1) ;

            // Setup the arguments to pass in
            $args = array(
                'order'     => 'ASC',
                'orderby'      => 'menu_order',
                'offset'    => $offset,
                'paged'    => $per_page

            // Gather the terms
            $terms = get_terms("dossiers", $args);

            $count = count($terms);
            if ( $count > 0 ){
                echo "<ul>";
                foreach ( $terms as $term ) {?>
                    <li class="article">
                        <a href="<?php echo get_term_link( $term ); ?>">
                                if ( get_field('banner', $term->taxonomy._.$term->term_id) ) { // check if the post has a Banner Image assigned to it.
                                    $image = get_field('banner', $term->taxonomy._.$term->term_id);
                                    echo '<img class="wp-post-image" src="'.$image[sizes]['thumbnail'].'" />';
                                else {
                                    echo '<img class="wp-post-image" src="' . get_bloginfo( 'stylesheet_directory' ) . '/img/missing-thumbnail.png" />';
                            <div class="meta-info" />
                                <div class="caption" data-category="<?php $category = get_the_category(); echo $category[0]->slug; ?>"><?php echo $term->name; ?> </div>
                 echo "</ul>";

<nav class="pagination">


            if($terms) {

                    $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 ), // 9 items per page
                        'type' => 'list',
                        'mid_size' => 5
                    ) );


<?php get_footer(); ?>
  • if you are seeing your index.php template, then this template is never being called, so the error might not be in this code. Check the url that you are getting for the other pages, to see that it's correct. Bear in mind index.php is the default template, when wordpress cant find any others that should be used. This is a very helpful page: codex.wordpress.org/Template_Hierarchy
    – Bill
    Commented Feb 18, 2014 at 18:13
  • ^Scroll down to 'visual overview'
    – Bill
    Commented Feb 18, 2014 at 18:14
  • The URLs seem to be correct: the original page is /category/dossiers/. When I use the pagination, I end up on /category/dossiers/page/2/. I suppose I'm not making it any easier for myself by using the pretty permalinks, but it must be possible, right? Commented Feb 18, 2014 at 18:22
  • I think the main problem is the fact that the code on the page above doesn't know what to do when on /page/2/. Maybe it isn't loading my category-page anymore? Or it just doesn't know what the /page/2/ means, even though that's what the get_query_var('paged') is for Commented Feb 18, 2014 at 18:26
  • 1
    Yes it will only load your category page on /category/dossiers. If you go to /category/dossiers?paged=2 I think you'll find it will work
    – Bill
    Commented Feb 18, 2014 at 18:27

1 Answer 1


It looks like you're trying to use get_terms() in the same way that you would use WP_Query() which you can't do.

'paged'    => $per_page

This is not a valid argument to pass to get_terms()

Also each post type has a rewrite rule to allow for pagination e.g. /2/, however that's not the same with terms, therefore WP is going to 404 it (it's only displaying index.php because you don't have a 404).

Unless you want to create your own pagination (using rewrite rules), the focus of the loop must be a post of some kind, not a term - so maybe it's best to think if there's a better way of doing this based around that.

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service and acknowledge you have read our privacy policy.

Not the answer you're looking for? Browse other questions tagged or ask your own question.