Advertisement
lonchbox

featured post loop

Mar 29th, 2012
107
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
PHP 1.08 KB | None | 0 0
  1. <?php
  2.                     // Get the page as an Object
  3.                     $featured_args = array(
  4.                         'posts_per_page' => 1,
  5.                         'post__in'  => get_option( 'sticky_posts' ),
  6.                         'public' => true,
  7.                         'ignore_sticky_posts' => 1,
  8.                         'post_type' => 'post'
  9.                     );
  10.  
  11.                     // The Featured Posts query.
  12.                     $featured = new WP_Query( $featured_args );
  13.  
  14.                     // Proceed only if published posts exist
  15.                     if ( $featured->have_posts() ) :
  16.  
  17.                     ?>
  18.  
  19.                 <section id="featured-posts">
  20.                     <h2 class="featured-heading"><?php _e( 'Destacado', 'lonchpress' ); ?></h2>
  21.  
  22.                 <?php
  23.                     // Let's roll.
  24.                     while ( $featured->have_posts() ) : $featured->the_post();
  25.  
  26.                     /**
  27.                      * We're going to add a class to our featured post for featured images
  28.                      * by default it'll have the feature-text class.
  29.                      */
  30.                     $feature_class = 'feature-text';
  31.                     ?>
  32.  
  33.                     <div class="row <?php echo $feature_class; ?>">
  34.                         <?php get_template_part( 'content', 'featured' ); ?>
  35.                     </div>
  36.                 <?php endwhile; ?>
  37.                 </section><!-- .featured-posts -->
  38.                 <?php endif; // End check for sticky posts. ?>
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement