Add sticky_class() template tag. see #7457

git-svn-id: https://develop.svn.wordpress.org/trunk@8637 602fd350-edb4-49c9-b593-d223f7449a82
This commit is contained in:
Ryan Boren
2008-08-13 18:21:52 +00:00
parent c53da5a523
commit 2b8caf9a1f
5 changed files with 40 additions and 12 deletions

View File

@@ -1523,14 +1523,16 @@ class WP_Query {
}
// Fetch sticky posts that weren't in the query results
$stickies__in = implode(',', array_map( 'absint', $sticky_posts ));
$stickies = $wpdb->get_results( "SELECT * FROM $wpdb->posts WHERE $wpdb->posts.ID IN ($stickies__in)" );
// TODO Make sure post is published or viewable by the current user
foreach ( $stickies as $sticky_post ) {
if ( 'publish' != $sticky_post->post_status )
continue;
array_splice($this->posts, $sticky_offset, 0, array($sticky_post));
$sticky_offset++;
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)" );
// TODO Make sure post is published or viewable by the current user
foreach ( $stickies as $sticky_post ) {
if ( 'publish' != $sticky_post->post_status )
continue;
array_splice($this->posts, $sticky_offset, 0, array($sticky_post));
$sticky_offset++;
}
}
}
@@ -1759,4 +1761,4 @@ function setup_postdata($post) {
return true;
}
?>
?>