• I’m using a customized version of Templatic’s SimpleSite 2 theme. It’s got a nice little “recent” content feed on the home page, and also has another area for the “most recent”. Problem is, you end up with redundant content.

    Looking for a way for the feed to skip the first one, since it’s already being displayed in the larger area.

    Here’s a link to the dev site and here’s the Simplesite 2 demo: http://templatic.com/demo/simplesite2/

    So here is the code for the “latest” module on the left:

    <div class="home_subcolumn alignleft">
      <h3>CURRENT FEATURE</h3>
      <?php $page = (get_query_var('paged')) ? get_query_var('paged') : 1; query_posts("cat=6&showposts=1&paged=$page"); while ( have_posts() ) : the_post()  ?>
    
      <div class="featuredwork">
        <?php $projectimg = get_post_meta($post->ID, 'projectimg', $single = true); ?>
        <a  href="<?php the_permalink() ?>">
        <?php if($projectimg !== '') { ?>
          <img src="<?php bloginfo('template_directory'); ?>/includes/thumb.php?src=<?php echo $projectimg; ?>&h=220&w=455&zc=1" alt="<?php the_title(); ?>" class="fimg" />
        <?php }
        else { echo'<div class="noimage_avilable">no image available</div>'; } ?>
        </a> </div> <!--featured work #end -->

    and here’s the right:

    <div class="home_subcolumn alignright">
      <h3>RECENT FEATURES</h3>
    
      <ul class="recentwork">
        <?php $page = (get_query_var('paged')) ? get_query_var('paged') : 1; query_posts("cat=6&showposts=6&paged=$page"); while ( have_posts() ) : the_post()  ?>
        <?php $projectimg = get_post_meta($post->ID, 'projectimg', $single = true); ?>
        <li id="post-<?php the_ID(); ?>"> <a  href="<?php the_permalink() ?>">
          <?php if($projectimg !== '') { ?>
           <img src="<?php bloginfo('template_directory'); ?>/includes/thumb.php?src=<?php echo $projectimg; ?>&h=80&w=130&zc=1" alt="<?php the_title(); ?>" />
          <?php }
        else { echo'<div class="noimage_avilable2">no image available</div>'; } ?>
          <?php the_title(); ?>
          </a> </li>
        <?php endwhile; ?>
      </ul>

    So the question is how can we tell the site to subtract the item displayed in the “latest” area from the ones that are displayed in the “recent” area, that way the content is not repeated?

Viewing 1 replies (of 1 total)
  • See the Codex The Loop:Multiple Loops in Action.

    This might do what you want:

    <?php if($projectimg !== '') { ?>
          <?php $featuredID = get_the_ID(); ?>
          <img src="<?php bloginfo('template_directory'); ?>/includes/thumb.php?src=<?php echo $projectimg; ?>&h=220&w=455&zc=1" alt="<?php the_title(); ?>" class="fimg" />
        <?php }
    <ul class="recentwork">
        <?php $page = (get_query_var('paged')) ? get_query_var('paged') : 1; query_posts("cat=6&showposts=6&paged=$page"); while ( have_posts() ) : the_post()  ?>
           <?php if ($featuredID == $post->ID) continue; ?>
           <?php $projectimg = get_post_meta($post->ID, 'projectimg', $single = true); ?>
Viewing 1 replies (of 1 total)

The topic ‘Subtracting first post from results’ is closed to new replies.