Make WordPress Core

Ticket #11072: query.php.diff

File query.php.diff, 1.1 KB (added by chrisscott, 16 years ago)
  • wp-includes/query.php

     
    23482348                        // Fetch sticky posts that weren't in the query results
    23492349                        if ( !empty($sticky_posts) ) {
    23502350                                $stickies__in = implode(',', array_map( 'absint', $sticky_posts ));
    2351                                 $stickies = $wpdb->get_results( "SELECT * FROM $wpdb->posts WHERE $wpdb->posts.ID IN ($stickies__in)" );
     2351                                // honor post type(s) if not set to any
     2352                                $stickies_where = '';
     2353                                if ( 'any' != $post_type ) {
     2354                                        if ( is_array( $post_type ) ) {
     2355                                                $post_types = join( "', '", $post_type );
     2356                                        } else {
     2357                                                $post_types = $post_type;
     2358                                        }
     2359                                        $stickies_where = "AND $wpdb->posts.post_type IN ('" . $post_types . "')";
     2360                                }
     2361                                $stickies = $wpdb->get_results( "SELECT * FROM $wpdb->posts WHERE $wpdb->posts.ID IN ($stickies__in) $stickies_where" );
    23522362                                /** @todo Make sure post is published or viewable by the current user */
    23532363                                foreach ( $stickies as $sticky_post ) {
    23542364                                        if ( 'publish' != $sticky_post->post_status )