Advertisement
alchymyth

showcase - recent

Feb 12th, 2013
184
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
PHP 1.91 KB | None | 0 0
  1.                 <section class="recent-posts">
  2.                     <h1 class="showcase-heading"><?php _e( 'Recent Posts', 'twentyeleven' ); ?></h1>
  3.  
  4.                     <?php
  5.  
  6.                     // Display our recent posts, showing full content for the very latest, ignoring Aside posts.
  7.                     $recent_args = array(
  8.                         'order' => 'DESC',
  9.                         'post__not_in' => get_option( 'sticky_posts' ),
  10.                         'tax_query' => array(
  11.                             array(
  12.                                 'taxonomy' => 'post_format',
  13.                                 'terms' => array( 'post-format-aside', 'post-format-link', 'post-format-quote', 'post-format-status' ),
  14.                                 'field' => 'slug',
  15.                                 'operator' => 'NOT IN',
  16.                             ),
  17.                         ),
  18.                         'no_found_rows' => true,
  19.                     );
  20.  
  21.                     // Our new query for the Recent Posts section.
  22.                     $recent = new WP_Query( $recent_args );
  23.  
  24.                     // The first Recent post is displayed normally
  25.                     if ( $recent->have_posts() ) : $recent->the_post();
  26.  
  27.                         // Set $more to 0 in order to only get the first part of the post.
  28.                         global $more;
  29.                         $more = 0;
  30.  
  31.                         get_template_part( 'content', get_post_format() );
  32.  
  33.                         echo '<ol class="other-recent-posts">';
  34.  
  35.                     endif;
  36.  
  37.                     // For all other recent posts, just display the title and comment status.
  38.                     while ( $recent->have_posts() ) : $recent->the_post(); ?>
  39.  
  40.                         <li class="entry-title">
  41.                             <a href="<?php the_permalink(); ?>" title="<?php echo esc_attr( sprintf( __( 'Permalink to %s', 'twentyeleven' ), the_title_attribute( 'echo=0' ) ) ); ?>" rel="bookmark"><?php the_title(); ?></a>
  42.                             <span class="comments-link">
  43.                                 <?php comments_popup_link( '<span class="leave-reply">' . __( 'Leave a reply', 'twentyeleven' ) . '</span>', __( '<b>1</b> Reply', 'twentyeleven' ), __( '<b>%</b> Replies', 'twentyeleven' ) ); ?>
  44.                             </span>
  45.                         </li>
  46.  
  47.                     <?php
  48.                     endwhile;
  49.  
  50.                     // If we had some posts, close the <ol>
  51.                     if ( $recent->post_count > 0 )
  52.                         echo '</ol>';
  53.                     ?>
  54.                 </section><!-- .recent-posts -->
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement