From dd1c8932aa1a6dea9e137449f9b7ea8782974a8d Mon Sep 17 00:00:00 2001 From: ryan Date: Mon, 6 Apr 2009 15:42:12 +0000 Subject: [PATCH] Don't trigger loop start in get_body_class(). Props Denis-de-Bernardy. fixes #9457 git-svn-id: http://svn.automattic.com/wordpress/trunk@10877 1a063a9b-81f0-0310-95a4-ce76da25c4cd --- wp-includes/post-template.php | 18 ++++++------------ 1 file changed, 6 insertions(+), 12 deletions(-) diff --git a/wp-includes/post-template.php b/wp-includes/post-template.php index 3bc817d1d1..f3a789f403 100644 --- a/wp-includes/post-template.php +++ b/wp-includes/post-template.php @@ -384,7 +384,8 @@ function get_body_class( $class = '' ) { $classes[] = 'error404'; if ( is_single() ) { - the_post(); + $wp_query->post = $wp_query->posts[0]; + setup_postdata($wp_query->post); $postID = $wp_query->post->ID; $classes[] = 'single postid-' . $postID; @@ -394,8 +395,6 @@ function get_body_class( $class = '' ) { $mime_prefix = array( 'application/', 'image/', 'text/', 'audio/', 'video/', 'music/' ); $classes[] = 'attachmentid-' . $postID . ' attachment-' . str_replace( $mime_prefix, "", "$mime_type" ); } - - rewind_posts(); } elseif ( is_archive() ) { if ( is_author() ) { $author = $wp_query->get_queried_object(); @@ -411,8 +410,9 @@ function get_body_class( $class = '' ) { $classes[] = 'tag-' . $tags->slug; } } elseif ( is_page() ) { - the_post(); - + $wp_query->post = $wp_query->posts[0]; + setup_postdata($wp_query->post); + $pageID = $wp_query->post->ID; $page_children = wp_list_pages("child_of=$pageID&echo=0"); @@ -424,17 +424,11 @@ function get_body_class( $class = '' ) { if ( is_page_template() ) $classes[] = 'page-template page-template-' . str_replace( '.php', '-php', get_post_meta( $pageID, '_wp_page_template', true ) ); - - rewind_posts(); } elseif ( is_search() ) { - the_post(); - - if ( have_posts() ) + if ( !empty($wp_query->posts) ) $classes[] = 'search-results'; else $classes[] = 'search-no-results'; - - rewind_posts(); } if ( is_user_logged_in() )