• I have set up a site with pages assigned to individual categories. The code I have in my category.php template displays all of the posts (using a custom post type) in the selected category, but when I insert the code needed to get the pagination to work, it displays all posts, regardless of category. I’m somewhat of a WordPress (and PHP) novice, and am likely missing something about how the code works.

    Here’s what I have currently:

    <?php $term = get_term_by( 'slug', get_query_var( 'term' ), get_query_var( 'category' ) ); ?>
    <?php $paged = (get_query_var('paged')) ? get_query_var('paged') : 1;
    query_posts( array('post_type' => 'lesson', 'category_name' => $term->slug, 'paged' => $paged));?>
    
    <?php if ( have_posts() ) :  while ( have_posts() ) : the_post(); ?>
    // loop here
    <?php endwhile; ?>
    <?php toolbox_content_nav( 'nav-below' ); ?>
    <?php endif; ?>
    <?php wp_reset_query(); ?>

    I’m using the Toolbox theme, which has built-in content navigation menus. I’ve also tried using wp_pagenavi code to no avail, so I think it’s a problem with how I’m using query_posts.

    Any help would be appreciated. Thanks!

Viewing 1 replies (of 1 total)
  • Couple of things to try:

    First, make sure that posts_per_page is not ‘-1’ by coding it into the query:

    query_posts( array('posts_per_page' => 5, 'post_type' => 'lesson', 'category_name' => $term->slug, 'paged' => $paged));?>

    If that doesn’t work, try using ‘get_query_var(‘page’)’ instead of ‘paged’.

    If neither of those work, see if a plugin may be interfering by disabling all plugins.

    If none of the above work, try your template in a different theme.

Viewing 1 replies (of 1 total)
  • The topic ‘Pagination on category pages not working’ is closed to new replies.