Forums

Give help. Get help.

  • # October 9, 2012 at 8:24 pm

    I can’t figure out how to paginate my categories.php. I have this special loop. I have to have it done this way. I am returning three posts and need to get the pagination working to display the rest of the posts

    Here is the full loop
    $paged = ( get_query_var( ‘paged’ ) ) ? get_query_var( ‘paged’ ) : 1;
    //get the child categories and only display 3 posts
    $allcats = get_categories(array(‘child_of’ => get_query_var(‘cat’), ‘number’ => 3,’order’=> ‘asc’, ‘paged’ => $paged));
    foreach ($allcats as $cat) :
    $args = array(
    ‘category__in’ => array($cat->term_id),
    );

    $customInCatQuery = new WP_Query($args);

    if ($customInCatQuery->have_posts()) :
    echo ‘

    ‘;

    ?>

    < ?php else :
    echo ‘No post published in:’.$cat->name;
    endif;
    wp_reset_query();
    endforeach;

    # October 9, 2012 at 10:50 pm

    You need to use [get_query_var()](http://codex.wordpress.org/Function_Reference/get_query_var “get_query_var”)

    # October 9, 2012 at 10:58 pm

    Example:

    $customInCatQuery = new WP_Query($args, ‘paged=’ . get_query_var( ‘paged’ ) );

Viewing 3 posts - 1 through 3 (of 3 total)

You must be logged in to reply to this topic.

icon-anchoricon-closeicon-emailicon-linkicon-logo-staricon-menuicon-nav-guideicon-searchicon-staricon-tag