• Skip to main content
  • Skip to forum navigation

StudioPress

  • Shop for Themes
  • My StudioPress

Forum navigation

  • Home
  • General Genesis Discussions
  • StudioPress Themes
  • Genesis Blocks
    • Genesis Blocks
    • Genesis Custom Blocks
  • Retired Themes
  • FAQs
  • Forum Rules
  • Internationalization and Translations
  • Forum Bugs and Suggestions
  • Forum Log In

Are You Using The WordPress Block Editor?

Genesis now offers plugins that help you build better sites faster with the WordPress block editor (Gutenberg). Try the feature-rich free versions of each plugin for yourself!

Genesis Blocks Genesis Custom Blocks

Do not duplicate posts with Genesis and Custom Loop

Welcome!

These forums are for general discussion on WordPress and Genesis. Official support for StudioPress themes is offered exclusively at My StudioPress. Responses in this forum are not guaranteed. Please note that this forum will require a new username, separate from the one used for My.StudioPress.

Log In
Register Lost Password

Community Forums › Forums › Archived Forums › Design Tips and Tricks › Do not duplicate posts with Genesis and Custom Loop

This topic is: not resolved

Tagged: child theme, loop

  • This topic has 1 reply, 2 voices, and was last updated 10 years, 11 months ago by Susan.
Viewing 2 posts - 1 through 2 (of 2 total)
  • Author
    Posts
  • July 4, 2014 at 11:53 am #112974
    Yeltsin Lima
    Member

    I'm using the Sample Child Theme to create a website for my client. But I do need some help.

    I created a page called home.php and I'm showing this code (It's a big code):

    <?php get_header(); ?>
    
        <!-- slider -->
        <div class="container">
    
            <div class="row">
    
                <div class="col-md-8">
    
                    <div class="row">
    
                        <div class="col-md-12 hidden-sm hidden-xs">
    
                            <?php putRevSlider("home-slider","homepage") ?>
    
                        </div>
    
                    </div>
    
                    <div class="row">
    
                        <div class="col-md-12 cat-name">
                            <p><span class="label label-primary">Reflexões</span></p>
                        </div>
    
                        <?php $categoria_home_um = new WP_Query('category_name=reflexoes&posts_per_page=3'); ?>
                        <?php while ($categoria_home_um->have_posts()) : $categoria_home_um->the_post(); $do_not_duplicate = $post->ID; ?>
                        <div class="col-md-4 col-sm-4">
                            <div class="thumbnail">
                                <?php 
                                if ( get_the_post_thumbnail($post_id) != '' ) {
    
                                  echo '<a href="'; the_permalink(); echo '" class="thumbnail-wrapper">';
                                   the_post_thumbnail( 'home-images' );
                                  echo '</a>';
    
                                } else {
    
                                 echo '<a href="'; the_permalink(); echo '" class="thumbnail-wrapper">';
                                 echo '<img class="img-responsive" src="';
                                 echo catch_that_image();
                                 echo '" alt="" />';
                                 echo '</a>';
    
                                }
                                ?>
                                <div class="caption">
                                    <h4><a href="<?php the_permalink(); ?>"><?php the_title(); ?></a></h4>
                                </div>
                            </div>
                        </div>
                        <?php endwhile;?>
    
                        <div class="col-md-12 cat-name">
                            <p><span class="label label-primary">Atitude</span></p>
                        </div>
    
                        <?php $categoria_home_dois = new WP_Query('category_name=atitude&posts_per_page=3'); ?>
                        <?php while ($categoria_home_dois->have_posts()) : $categoria_home_dois->the_post(); $do_not_duplicate = $post->ID; ?>
                        <div class="col-md-4 col-sm-4">
                            <div class="thumbnail">
                                <?php 
                                if ( get_the_post_thumbnail($post_id) != '' ) {
    
                                  echo '<a href="'; the_permalink(); echo '" class="thumbnail-wrapper">';
                                   the_post_thumbnail( 'home-images' );
                                  echo '</a>';
    
                                } else {
    
                                 echo '<a href="'; the_permalink(); echo '" class="thumbnail-wrapper">';
                                 echo '<img class="img-responsive" src="';
                                 echo catch_that_image();
                                 echo '" alt="" />';
                                 echo '</a>';
    
                                }
                                ?>
                                <div class="caption">
                                    <h4><a href="<?php the_permalink(); ?>"><?php the_title(); ?></a></h4>
                                </div>
                            </div>
                        </div>
                        <?php endwhile;?>
    
                        <div class="col-md-12 cat-name">
                            <p><span class="label label-primary">Comportamento</span></p>
                        </div>
    
                        <?php $categoria_home_tres = new WP_Query('category_name=comportamento&posts_per_page=3'); ?>
                        <?php while ($categoria_home_tres->have_posts()) : $categoria_home_tres->the_post(); $do_not_duplicate = $post->ID; ?>
    
                        <div class="col-md-4 col-sm-4">
                            <div class="thumbnail">
                                <?php 
                                if ( get_the_post_thumbnail($post_id) != '' ) {
    
                                  echo '<a href="'; the_permalink(); echo '" class="thumbnail-wrapper">';
                                   the_post_thumbnail( 'home-images' );
                                  echo '</a>';
    
                                } else {
    
                                 echo '<a href="'; the_permalink(); echo '" class="thumbnail-wrapper">';
                                 echo '<img class="img-responsive" src="';
                                 echo catch_that_image();
                                 echo '" alt="" />';
                                 echo '</a>';
    
                                }
                                ?>
                                <div class="caption">
                                    <h4><a href="<?php the_permalink(); ?>"><?php the_title(); ?></a></h4>
                                </div>
                            </div>
                        </div>
                        <?php endwhile;?>
    
                    </div>
    
                    <div class="row">
    
                        <div class="col-md-12">
    
                            <?php genesis_standard_loop(); ?>
    
                        </div>
    
                    </div>
    
                </div>
    
                <div class="col-md-4">
                    <?php get_sidebar(); ?>
                </div>
    
            </div>
    
        </div>
    
    <?php get_footer(); ?>

    As you can see I'm repeating three loops. The only difference is the "category_name". EDIT: I was able to solve the first part of my "error" using this article.

    But I also need to remove the post from the "big loop" (the Genesis Loop). So the post needs to appear only one time (It can shows "freely" on Recent Posts widget but not in the main loop).

    So see the new home.php using the markup from the other article:

    <?php get_header(); ?>
    
        <!-- slider -->
        <div class="container">
    
            <div class="row">
    
                <div class="col-md-8">
    
                    <div class="row">
    
                        <div class="col-md-12 hidden-sm hidden-xs">
    
                            <?php putRevSlider("home-slider","homepage") ?>
    
                        </div>
    
                    </div>
    
                    <div class="row">
    
                        <div class="col-md-12 cat-name">
                            <p><span class="label label-primary">Reflexões</span></p>
                        </div>
    
                        <?php   $do_not_duplicate = array(); ?>
                        <?php   $mosaics = new WP_Query('category_name=reflexoes&posts_per_page=3'); ?>
                        <?php   while ($mosaics->have_posts()) : $mosaics->the_post(); ?>
                        <?php   $do_not_duplicate[] = $post->ID; ?>
                        <div class="col-md-4 col-sm-4">
                            <div class="thumbnail">
                                <?php 
                                if ( get_the_post_thumbnail($post_id) != '' ) {
    
                                  echo '<a href="'; the_permalink(); echo '" class="thumbnail-wrapper">';
                                   the_post_thumbnail( 'home-images' );
                                  echo '</a>';
    
                                } else {
    
                                 echo '<a href="'; the_permalink(); echo '" class="thumbnail-wrapper">';
                                 echo '<img class="img-responsive" src="';
                                 echo catch_that_image();
                                 echo '" alt="" />';
                                 echo '</a>';
    
                                }
                                ?>
                                <div class="caption">
                                    <h4><a href="<?php the_permalink(); ?>"><?php the_title(); ?></a></h4>
                                </div>
                            </div>
                        </div>
                        <?php   endwhile; wp_reset_postdata(); ?>
    
                        <div class="col-md-12 cat-name">
                            <p><span class="label label-primary">Atitude</span></p>
                        </div>
    
                        <?php   $mosaics = new WP_Query( array( 'category_name' => 'atitude', 'posts_per_page' => 3, 'post__not_in' => $do_not_duplicate ) ); ?>
                        <?php   while ($mosaics->have_posts()) : $mosaics->the_post(); ?>
                        <?php   $do_not_duplicate[] = $post->ID; ?>
                        <div class="col-md-4 col-sm-4">
                            <div class="thumbnail">
                                <?php 
                                if ( get_the_post_thumbnail($post_id) != '' ) {
    
                                  echo '<a href="'; the_permalink(); echo '" class="thumbnail-wrapper">';
                                   the_post_thumbnail( 'home-images' );
                                  echo '</a>';
    
                                } else {
    
                                 echo '<a href="'; the_permalink(); echo '" class="thumbnail-wrapper">';
                                 echo '<img class="img-responsive" src="';
                                 echo catch_that_image();
                                 echo '" alt="" />';
                                 echo '</a>';
    
                                }
                                ?>
                                <div class="caption">
                                    <h4><a href="<?php the_permalink(); ?>"><?php the_title(); ?></a></h4>
                                </div>
                            </div>
                        </div>
                        <?php   endwhile; wp_reset_postdata(); ?>
    
                        <div class="col-md-12 cat-name">
                            <p><span class="label label-primary">Comportamento</span></p>
                        </div>
    
                        <?php   $mosaics = new WP_Query( array( 'category_name' => 'comportamento', 'posts_per_page' => 3, 'post__not_in' => $do_not_duplicate ) ); ?>
                        <?php   while ($mosaics->have_posts()) : $mosaics->the_post(); ?>
                        <?php   $do_not_duplicate[] = $post->ID; ?>
    
                        <div class="col-md-4 col-sm-4">
                            <div class="thumbnail">
                                <?php 
                                if ( get_the_post_thumbnail($post_id) != '' ) {
    
                                  echo '<a href="'; the_permalink(); echo '" class="thumbnail-wrapper">';
                                   the_post_thumbnail( 'home-images' );
                                  echo '</a>';
    
                                } else {
    
                                 echo '<a href="'; the_permalink(); echo '" class="thumbnail-wrapper">';
                                 echo '<img class="img-responsive" src="';
                                 echo catch_that_image();
                                 echo '" alt="" />';
                                 echo '</a>';
    
                                }
                                ?>
                                <div class="caption">
                                    <h4><a href="<?php the_permalink(); ?>"><?php the_title(); ?></a></h4>
                                </div>
                            </div>
                        </div>
                        <?php   endwhile; wp_reset_postdata(); ?>
    
                    </div>
    
                    <div class="row">
    
                        <div class="col-md-12">
    
                            <?php genesis_standard_loop(); ?>
    
                        </div>
    
                    </div>
    
                </div>
    
                <div class="col-md-4">
                    <?php get_sidebar(); ?>
                </div>
    
            </div>
    
        </div>
    
    <?php get_footer(); ?>

    Great, but the <?php genesis_standard_loop(); ?> still shows the post (duplicated). How can I fix this thing.

    By the way: any suggestion to improve the markup of the code? 🙂

    Thanks.


    I’m not from StudioPress, I just like to help people! 🙂

    http://www.simplescoisasdavida.com/
    August 6, 2014 at 6:48 am #117326
    Susan
    Moderator

    As you posted this over a month ago, I hope your issue was resolved. If not, check back in, and I will escalate.

    Thanks!

  • Author
    Posts
Viewing 2 posts - 1 through 2 (of 2 total)
  • The forum ‘Design Tips and Tricks’ is closed to new topics and replies.

CTA

Ready to get started? Create a site or shop for themes.

Create a site with WP EngineShop for Themes

Footer

StudioPress

© 2025 WPEngine, Inc.

Products
  • Create a Site with WP Engine
  • Shop for Themes
  • Theme Features
  • Get Started
  • Showcase
Company
  • Brand Assets
  • Terms of Service
  • Accptable Usse Policy
  • Privacy Policy
  • Refund Policy
  • Contact Us
Community
  • Find Developers
  • Forums
  • Facebook Group
  • #GenesisWP
  • Showcase
Resources
  • StudioPress Blog
  • Help & Documentation
  • FAQs
  • Code Snippets
  • Affiliates
Connect
  • StudioPress Live
  • StudioPress FM
  • Facebook
  • Twitter
  • Dribbble