Created
October 29, 2013 20:51
-
-
Save data-enhanced/7222372 to your computer and use it in GitHub Desktop.
Exclude a certain post from the loop.
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
| From: | |
| http://wordpress.org/support/topic/multiple-loops-if-first-post-in-loop-1-matches-first-post-in-loop-2-skip | |
| Add this after the query: | |
| $check = get_posts('cat=3&numberposts=1'); | |
| if ( $check[0]->ID == $post->ID ) continue; | |
| Sample loop: | |
| <?php $args = array( 'post_type' => 'post'); | |
| $loop = new WP_Query( $args ); ?> | |
| <?php while ( $loop->have_posts() ) : $loop->the_post(); | |
| $check = get_posts('category_name=featured&numberposts=1'); | |
| if ($check[0]-> ID == $post->ID) continue; ?> | |
| <a href="<?php the_permalink(); ?>" class="item-link isotope-item"> | |
| <article class="feed-item featured-story <?php the_field('isotope_size') ?>"> | |
| <div class="<?php the_field('isotope-view')?>"> | |
| <?php if ( has_post_thumbnail() ) { ?> | |
| <?php the_post_thumbnail('full'); ?> | |
| <?php } ?> | |
| <h2><?php the_title(); ?></h2> | |
| <div class="item-description <?php the_field('isotope-mask') ?>"> | |
| <p><?php the_excerpt(); ?></p> | |
| <div class="byline"> | |
| "Author's Name " | |
| <span class="btn">Read more...</span> | |
| </div> | |
| </div> | |
| </div> | |
| </article> | |
| </a> | |
| <?php endwhile ?> |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment