Make WordPress Core


Ignore:
Timestamp:
11/05/2009 03:52:01 PM (17 years ago)
Author:
ryan
Message:

Honor Post Type for Sticky Posts. Props chrisscott. fixes #11072

File:
1 edited

Legend:

Unmodified
Added
Removed
  • trunk/wp-includes/query.php

    r12127 r12143  
    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 && '' != $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 ) {
Note: See TracChangeset for help on using the changeset viewer.