I have a page with multiple loops, but the first loop repeats on the second (or Older) page. I want to keep the formatting but stop the post from repeating.
You can see the problem here: http://violentology.com/blog/
In my index.php file, I have the code:
<table width="980" border="0" cellspacing="0" cellpadding="0">
<tr>
<td colspan="3" style="background-color:#000">
<?php get_the_image( array( 'meta_key' => 'feature_img', 'size' => 'full size', 'height' => '450', 'image_class' => 'post-feature-1' ) ); ?></td>
</tr>
<tr><td height="10"></td></tr>
<tr>
<td valign="top">
<div id="main-col">
<?php get_template_part( 'loop', 'index' ); ?>
</div>
</td>
<td valign="top" id="mainsidebartd">
<div id="linksidebar">
<?php get_sidebar(); ?>
</div>
</td>
<td width="10px"> </td>
</tr>
</table>`
In my loop, the code is as follows:
<!-- First Loop -->
<div id="first_post">
<?php $my_query = new WP_Query('posts_per_page=1');
while ($my_query->have_posts()) : $my_query->the_post();
$do_not_duplicate = $post->ID;?>
<!-- GETTING POST TITLE -->
<h2><a href="https://wordpress.stackexchange.com/questions/75333/<?php the_permalink(); ?>" title="<?php printf( esc_attr__( 'Permalink to %s', 'twentyten' ), the_title_attribute( 'echo=0' ) ); ?>" rel="bookmark"><?php the_title(); ?></a></h2>
<!-- GETTING DATE AUTHOR AND COMMENTS -->
<div class="date"><em><?php the_time('F jS, Y') ?> by <?php the_author_posts_link() ?></em> | <em><?php comments_popup_link( __( 'Leave a comment', 'twentyten' ), __( '1 Comment', 'twentyten' ), __( '% Comments', 'twentyten' ) ); ?></em>
</div>
<!-- GETTING ACTUAL POST -->
<?php if ( is_archive() || is_search() ) : // Only display excerpts for archives and search. ?>
<?php the_excerpt(); ?>
<?php else : ?>
<?php the_content(); ?>
<?php endif; ?>
<?php endwhile; ?>
</div>
<!-- Second Loop -->
<?php /* Start the Loop. */ ?>
<?php if (have_posts()) : while ( have_posts() ) : the_post();
if( $post->ID == $do_not_duplicate ) continue; ?>
<div id="singlepost"> <!-- POSITIONS INDIVIDUAL POSTS -->
<div class="post-box"><?php get_the_image( array( 'meta_key' => 'feature_img', 'size' => 'medium', 'height' => '200', 'image_class' => 'post-feature' ) ); ?></div>
<!-- GETTING POST TITLE -->
<h2><a href="https://wordpress.stackexchange.com/questions/75333/<?php the_permalink(); ?>" title="<?php printf( esc_attr__( 'Permalink to %s', 'twentyten' ), the_title_attribute( 'echo=0' ) ); ?>" rel="bookmark"><?php the_title(); ?></a></h2>
<!-- GETTING DATE AUTHOR AND COMMENTS -->
<div class="date"><em><?php the_time('F jS, Y') ?> by <?php the_author_posts_link() ?></em> | <em><?php comments_popup_link( __( 'Leave a comment', 'twentyten' ), __( '1 Comment', 'twentyten' ), __( '% Comments', 'twentyten' ) ); ?></em>
</div>
<!-- GETTING ACTUAL POST -->
<?php if ( is_archive() || is_search() ) : // Only display excerpts for archives and search. ?>
<?php the_excerpt(); ?>
<?php else : ?>
<?php the_content('Continue Reading',FALSE,''); ?>
<?php endif; ?>
</div>
<?php endwhile; // End the loop. ?>
<?php endif; ?>
<div id="postnav" class="postnav">
<?php next_posts_link('« Older') ?> | <?php previous_posts_link('Newer »') ?>
</div>`