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

git-svn-id: https://develop.svn.wordpress.org/trunk@12143 602fd350-edb4-49c9-b593-d223f7449a82
This commit is contained in:
Ryan Boren 2009-11-05 15:52:01 +00:00
parent af42a894f0
commit 3f9f8dc3d6
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 )