0

I am trying to have a s all box on my home page that will show the most recent 4 custom posts that are set with a featured tag. It is working and is showing the image of the most recent post and then just listing out the other 3 post titles under it which I want but I am tying to figure out a way to have the featured post that it is showing an image for change weekly to one of the other 4 posts so that they rotate.

Anyone have some suggestions of how I can do this?

<?php $recent = new WP_Query('post_type=stories&story_tag=featured&posts_per_page=4' ); ?>
<?php $count = 0; ?>
<?php while( $recent->have_posts() ) : $recent->the_post(); ?>
<?php $count++; ?>
<?php if ($count < 2) : ?>
  <a href="<?php the_permalink() ?>" rel="bookmark" title="Permanent Link to    <?php the_title_attribute(); ?>"><?php  
if ( has_post_thumbnail()):  
the_post_thumbnail( 'feed-fixed' );  
endif;  ?></a>


      <h3><a href="<?php the_permalink() ?>" rel="bookmark" title="Permanent  Link to <?php the_title_attribute(); ?>"><?php the_title(); ?></a></h3>
  <?php else : ?>
<ul>
<li>
      <h3><a href="<?php the_permalink() ?>" rel="bookmark" title="Permanent  Link to <?php the_title_attribute(); ?>"><?php the_title(); ?></a></h3>

</li>
</ul>
<?php endif; ?>
<?php endwhile; ?>
0

You could add time params to your WP_Query. Posts that have the same tag and were published during the current week:

<?php $recent = new WP_Query('post_type=stories&story_tag=featured&posts_per_page=4&year='.date('Y').'&w='.date('W'); ?>

Source: the codex and me since i recently did this.

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service, privacy policy and cookie policy

Not the answer you're looking for? Browse other questions tagged or ask your own question.