Title: &quot;Featured&quot; Section using multiple &quot;get_posts&quot; queries
Last modified: August 20, 2016

---

# "Featured" Section using multiple "get_posts" queries

 *  [KeenanPayne](https://wordpress.org/support/users/keenanpayne/)
 * (@keenanpayne)
 * [13 years, 7 months ago](https://wordpress.org/support/topic/featured-section-using-multiple-get_posts-queries/)
 * Hello all,
 * So I own and designed the site Default Prime ([http://defaultprime.com](http://defaultprime.com)).
   I am coding the featured posts section at the top, and am having quite a bit 
   of trouble. Here’s the code that I am using:
 *     ```
       <ul>
       	<li>
       	<div class="featuredleft"> <!--Show-->
       		<?php
       			$args = array( 'numberposts' => 1, 'category' => 4809, );
       			$lastposts = get_posts( $args );
       				foreach($lastposts as $post) : setup_postdata($post); ?>
       		<?php if ( has_post_thumbnail() ) {
       			the_post_thumbnail( 'featuredleft' );
       		} ?>
       		<h2><a href="<?php the_permalink(); ?>" title="<?php the_title(); ?>"><?php the_title(); ?></a></h2>
       		<?php echo my_excerpt(30); ?>
       		<?php endforeach; ?>
       	</div>
       	</li>
       	<li>
       	<div class="featuredlast"><!--Podcast-->
       		<?php
       			$args = array( 'numberposts' => 1, 'category' => 2, );
       			$lastposts = get_posts( $args );
       				foreach($lastposts as $post) : setup_postdata($post); ?>
       		<?php if ( has_post_thumbnail() ) {
       			the_post_thumbnail( 'featuredmiddle' );
       		} ?>
       		<h2><a href="<?php the_permalink(); ?>" title="<?php the_title(); ?>"><?php the_title(); ?></a></h2>
       		<?php echo my_excerpt(20); ?>
       		<?php endforeach; ?>
       	</div>
       	</li>
       	<li>
       	<div class="featuredmiddle"><!--Review-->
       		<?php
       			$args = array( 'numberposts' => 1, 'category' => 3, );
       			$lastposts = get_posts( $args );
       				foreach($lastposts as $post) : setup_postdata($post); ?>
       		<?php if ( has_post_thumbnail() ) {
       			the_post_thumbnail( 'featuredmiddle' );
       		} ?>
       		<h2><a href="<?php the_permalink(); ?>" title="<?php the_title(); ?>"><?php the_title(); ?></a></h2>
       		<?php echo my_excerpt(20); ?>
       		<?php endforeach; ?>
       	</div>
       	</li>
       	<li>
       	<div class="featuredmiddle"><!--Column-->
       		<?php
       			$args = array( 'numberposts' => 1, 'category' => 4743, );
       			$lastposts = get_posts( $args );
       				foreach($lastposts as $post) : setup_postdata($post); ?>
       		<?php if ( has_post_thumbnail() ) {
       			the_post_thumbnail( 'featuredmiddle' );
       		} ?>
       		<h2><a href="<?php the_permalink(); ?>" title="<?php the_title(); ?>"><?php the_title(); ?></a></h2>
       		<?php echo my_excerpt(20); ?>
       		<?php endforeach; ?>
       	</div>
       	</li>
       	<li>
       	<div class="featuredmiddle"><!--Editorial-->
       		<?php
       			$args = array( 'numberposts' => 1, 'category' => 5768, );
       			$lastposts = get_posts( $args );
       				foreach($lastposts as $post) : setup_postdata($post); ?>
       		<?php if ( has_post_thumbnail() ) {
       			the_post_thumbnail( 'featuredmiddle' );
       		} ?>
       		<h2><a href="<?php the_permalink(); ?>" title="<?php the_title(); ?>"><?php the_title(); ?></a></h2>
       		<?php echo my_excerpt(20); ?>
       		<?php endforeach; ?>
       	</div>
       	</li>
       	</ul>
       ```
   
 * The problem is, even though I have five instances of the “get_post” query to 
   display the categories that I want, only four of them are showing up (screenshot
   here: [http://i.imgur.com/Hpe0I.png](http://i.imgur.com/Hpe0I.png)).
 * Could anybody just take a quick look over my code and see if I have any errors?
   I have been working for hours and cannot find anywhere that I have made a mistake
   and would love to get this fixed soon.
 * Thanks everybody!
    -Keenan

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

 *  [Michael](https://wordpress.org/support/users/alchymyth/)
 * (@alchymyth)
 * [13 years, 7 months ago](https://wordpress.org/support/topic/featured-section-using-multiple-get_posts-queries/#post-3080858)
 * ‘featuredlast’ = cat 2 does not seem to have any posts.
 *  Thread Starter [KeenanPayne](https://wordpress.org/support/users/keenanpayne/)
 * (@keenanpayne)
 * [13 years, 7 months ago](https://wordpress.org/support/topic/featured-section-using-multiple-get_posts-queries/#post-3080859)
 * Wow, I can’t believe I overlooked that. I guess I just didn’t even think it could
   be that.
 * Thank you very much for helping me with that, I really appreciate it.

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

The topic ‘"Featured" Section using multiple "get_posts" queries’ is closed to new
replies.

## Tags

 * [get_posts](https://wordpress.org/support/topic-tag/get_posts/)
 * [posts](https://wordpress.org/support/topic-tag/posts/)
 * [query](https://wordpress.org/support/topic-tag/query/)

 * In: [Hacks](https://wordpress.org/support/forum/plugins-and-hacks/hacks/)
 * 2 replies
 * 2 participants
 * Last reply from: [KeenanPayne](https://wordpress.org/support/users/keenanpayne/)
 * Last activity: [13 years, 7 months ago](https://wordpress.org/support/topic/featured-section-using-multiple-get_posts-queries/#post-3080859)
 * Status: not resolved

## Topics

### Topics with no replies

### Non-support topics

### Resolved topics

### Unresolved topics

### All topics
