The Lodge is members-only design/dev videos and Office Hours.

Next Office Hours Session: "Implementing an SVG Icon System" Nov 30 - 6:00 PM Eastern

paginate get_categories ?

  • # 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;

    # October 9, 2012 at 10:50 pm

    You need to use [get_query_var()]( “get_query_var”)

    # October 9, 2012 at 10:58 pm

    This reply has been reported for inappropriate content.

    I am using that, it’s not working. I will edit the code to show that above

    # October 9, 2012 at 10:58 pm


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

    # October 9, 2012 at 11:01 pm

    This reply has been reported for inappropriate content.

    I don’t think that will work. I will try it now though. But I can’t use the wp_query. The only way I can seem to get the child categories is by using the foreach loop. I just tried using child_of in a wp_query and got nothing back. I tried to remove the foreach $allcats loop above and replace it with wp_query and I got three posts saying “No post published”

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

You must be logged in to reply to this topic.

There's a whole bunch of content on CSS-Tricks.

Search for Stuff   •   Browse the Archives

Get the Newsletter ... or get the RSS feed