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

git-svn-id: http://svn.automattic.com/wordpress/trunk@12143 1a063a9b-81f0-0310-95a4-ce76da25c4cd
This commit is contained in:
ryan 2009-11-05 15:52:01 +00:00
parent 2498bb6cae
commit c3041b4f56
1 changed files with 11 additions and 1 deletions

View File

@ -2348,7 +2348,17 @@ class WP_Query {
// Fetch sticky posts that weren't in the query results
if ( !empty($sticky_posts) ) {
$stickies__in = implode(',', array_map( 'absint', $sticky_posts ));
$stickies = $wpdb->get_results( "SELECT * FROM $wpdb->posts WHERE $wpdb->posts.ID IN ($stickies__in)" );
// honor post type(s) if not set to any
$stickies_where = '';
if ( 'any' != $post_type && '' != $post_type ) {
if ( is_array( $post_type ) ) {
$post_types = join( "', '", $post_type );
} else {
$post_types = $post_type;
}
$stickies_where = "AND $wpdb->posts.post_type IN ('" . $post_types . "')";
}
$stickies = $wpdb->get_results( "SELECT * FROM $wpdb->posts WHERE $wpdb->posts.ID IN ($stickies__in) $stickies_where" );
/** @todo Make sure post is published or viewable by the current user */
foreach ( $stickies as $sticky_post ) {
if ( 'publish' != $sticky_post->post_status )