Make WordPress Core

Ticket #17198: 17198.showcase.diff

File 17198.showcase.diff, 1.3 KB (added by kawauso, 12 years ago)

Make showcase.php query usage more efficient

  • wp-content/themes/twentyeleven/showcase.php

     
    2323                                <?php
    2424                                        // See if we have any sticky posts and use the latest to create a featured post
    2525                                        $sticky = get_option( 'sticky_posts' );
     26
     27                                        // Let's roll.
     28                                        if ( $sticky ) :
     29
    2630                                        $featured_args = array(
    2731                                                'posts_per_page' => 1,
    2832                                                'post__in' => $sticky,
     
    3034                                       
    3135                                        $featured = new WP_Query();
    3236                                        $featured->query( $featured_args );
    33                                
    34                                         // Let's roll.
    35                                         if ( $sticky ) :
    36                                        
     37
    3738                                        $featured->the_post();
    3839                                       
    3940                                        // We're going to add a class to our featured post for featured images
     
    9596                                        );
    9697                                        $recent = new WP_Query();
    9798                                        $recent->query( $recent_args );
    98                                         $counter = 0;
    9999                                       
    100100                                        while ( $recent->have_posts() ) : $recent->the_post();
    101101                                                // set $more to 0 in order to only get the first part of the post
    102102                                                global $more;
    103103                                                $more = 0;                                     
    104                                                 $counter++;
    105104                                               
    106                                                 if ( 1 == $counter ) :
     105                                                if ( $recent->current_post == 0 ) :
    107106                                                        get_template_part( 'content', get_post_format() );
    108107                                                        echo '<ol class="other-recent-posts">';
    109108