• I have 2 category (parent and child) with one template for both. I want to use query_posts for pagination. I’m use posts_per_page for limit posts on page. All work’s fine except one things – I cant see child category without parent. If I dont use query_posts all works fine but I cant limit posts on page.

    My code before loop.

    <?php
        $limit = 6;
        $catid = 4,6;
        $catid = strpos( $catid , ',' ) ? explode( ',' , $catid ) : array( (int) $catid );
        $paged = (get_query_var('paged')) ? get_query_var('paged') : 1;
        query_posts(array('category__in'=>$catid,'posts_per_page'=>$limit,'paged'=>$paged));
        $wp_query->is_archive = true; $wp_query->is_home = false;
        ?>

    Please help me understand!

Viewing 2 replies - 1 through 2 (of 2 total)
  • To display posts from either category 2 OR 6, you could use cat as mentioned above, or by using category__in (note this does not show posts from any children of these categories):

    query_posts(array(‘category__in’ => array(2,6)));

    http://codex.wordpress.org/Function_Reference/query_posts#Category_Parameters

    Thread Starter Deniska

    (@deniska)

    Thank you for answer. I’m try to use all method that I know but they doesn’t work.
    I try this

    <?php
        $limit = 6;
        $catid = 4,6;
        $paged = (get_query_var('paged')) ? get_query_var('paged') : 1;
        query_posts('showposts=' . $limit . '&paged=' . $paged . '&cat=' . $catid);
        $wp_query->is_archive = true; $wp_query->is_home = false;
        ?>

    Page show all posts and doesnt show only one category.

Viewing 2 replies - 1 through 2 (of 2 total)

The topic ‘Posts_per_page work not correct’ is closed to new replies.