Query posts for 1 category & set the number of posts to display

So I’m trying to look pull posts that are only in the blog category and display 10 posts on the page. I’m thinking this should work, but I’m not sure why it isn’t. The page is still pulling posts from all categories.

         <?php 
           $blogposts = new WP_Query(array(
            'category_in' => 'Blog',
					'posts_per_page' => 5000,
            ));
					?>
            
            
					<?php query_posts('blogposts'); ?>
            

						<?php if ( $blogposts->have_posts() ) : while ( $blogposts->have_posts() ) : $blogposts->the_post(); ?>
                ................

The ‘category_in’ parameter takes the category id. You want to use ‘category_name’ which takes the category slug (ie all lowercase, spaces replaces by -). Check out the documentation here: https://codex.wordpress.org/Class_Reference/WP_Query

1 Like

This topic was automatically closed 91 days after the last reply. New replies are no longer allowed.