New WordPress WP Query using posts from certain categories
There are some errors in your code, you have to change: $the_query -> have_posts() to $the_query->have_posts() $the_query -> the_post() to $the_query->the_post() WP_Query array(…) to WP_Query(array(…)) ‘showposts=6’ to ‘posts_per_page’ => 6 Try this instead $the_query = new WP_Query( array( ‘category_name’ => ‘portfolio’, ‘posts_per_page’ => 6 ) ); while ($the_query->have_posts()) : $the_query->the_post(); the_post_thumbnail(); endwhile;