"Featured" Section using multiple "get_posts" queries
-
Hello all,
So I own and designed the site Default Prime (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).
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)
Viewing 2 replies - 1 through 2 (of 2 total)
- The topic ‘"Featured" Section using multiple "get_posts" queries’ is closed to new replies.