• I am not able to list all category posts with this code… Is there anything I’m doing wrong?

    $cat_id = get_cat_ID('Building Designs');
    	$args=array(
    	  'cat' => $cat_id,
    	  'post_type' => 'post',
    	  'post_status' => 'publish',
    	  'posts_per_page' => -1,
    	  'caller_get_posts'=> 1
    	);
    	$my_query = null;
    	$my_query = new WP_Query($args);
            while ($my_query->have_posts()) : $my_query->the_post();
            the_permalink();
            endwhile;

    or

    $args=array(
    	  'cat' => 4,
    	  'posts_per_page' => 2,
    	);
    
    // The Query
    $query = new WP_Query( $args );
    
    // The Loop
    if ( $query->have_posts() ) {
    	while ( $query->have_posts() ) {
    		$query->the_post();
    		echo '<li>' . get_the_title() . '</li>';
    	}
    } else {
    	// no posts found
    }
    /* Restore original Post Data */
    wp_reset_postdata();

    Both of them do not display all the posts. It displays only a few. When I change the

    posts_per_page=>-1

    to say 2, it still displays more than 2.

    http://wordpress.org/extend/plugins/list-category-posts/

  • The topic ‘List all posts in category’ is closed to new replies.