WordPress.org

Ready to get started?Download WordPress

Forums

Exclude posts repetition in the loop on second page (2 posts)

  1. Satiro
    Member
    Posted 2 years ago #

    Hi,
    in my theme I have a custom homepage. Its loop code is this:

    <?php $temp_query = clone $wp_query; ?>
    <?php $my_query = new WP_Query('posts_per_page=3');
    	while ($my_query->have_posts()) : $my_query->the_post();
    		$do_not_duplicate[] = $post->ID;?>
    
    		<!-- Do stuff... -->
    		<?php comments_template(); ?>
    
    <?php endwhile; ?>

    This code is repeated for each group category on homepage, but in the normal loop on second page, some posts is repeated.

    The loop code for second page, and other paged, is this:

    <?php while (have_posts()) : the_post(); ?>

    You can see the results on this link: My blog

    How can I resolve?

  2. shihabmalayil
    Member
    Posted 1 year ago #

    This is my code...repeating content after post.
    How can i solve this problem?

    (theme Page) for showing content of wordpress page
    //
    <?php if(have_posts()):
    while(have_posts()): the_post(); ?>
    <h1><?php the_title();?></h1>
    <p><?php the_content();?></p>
    <?php endwhile;
    else :
    endif;?>
    //

    (WP Page) for showing wordpress post

    //
    <?php query_posts('cat=4&showposts=8'); ?>
    <?php if (have_posts()) : while (have_posts()) : the_post(); ?>
    <?php the_title()?>
    <?php the_excerpt();?>
    <?php endwhile; endif; ?>
    //

    thanks
    Sh!hab

Topic Closed

This topic has been closed to new replies.

About this Topic