Duplicate posts appearing
-
Hi! I’m customizing the Expound theme, and I put a loop so I could show a single complete post from a certain category. It’s the first post at left of the Widget Area, below Rodin’s Thinker: https://noblogdododo.com
I’ve excluded the category from all that posts above, but I can’t exclude the whole category from the posts below that complete post. But I’d like to prevent the post from appearing again right below the complete post.
I found this solution
https://wpengineer.com/1719/filter-duplicate-posts-in-the-loop/
So I put this code in my added loop
$do_not_duplicate[] = $post->ID;
And now I’m supposed to add this code in the main loop
'post__not_in' => $do_not_duplicate
I found the beginning of the loop in the index.php file, right after I put my “custom” loop, but I don’t know where to put that second line of code. I’m pasting the code of what I suppose it’s the theme’s main loop:
<?php if ( have_posts() ) : ?> <?php /* Start the Loop */ ?> <?php while ( have_posts() ) : the_post(); ?> <?php /* Include the Post-Format-specific template for the content. * If you want to overload this in a child theme then include a file * called content-___.php (where ___ is the Post Format name) and that will be used instead. */ get_template_part( 'content', get_post_format() ); ?> <?php endwhile; ?> <?php expound_content_nav( 'nav-below' ); ?> <?php elseif ( ! is_home() || is_paged() ) : ?> <?php get_template_part( 'no-results', 'index' ); ?> <?php else : ?> <?php $featured_posts = expound_get_featured_posts(); if ( ! $featured_posts->have_posts() ) get_template_part( 'no-results', 'index' ); ?> <?php endif; ?> </div><!-- #content --> </div><!-- #primary -->
Thank you!
- The topic ‘Duplicate posts appearing’ is closed to new replies.