From a6fac0db89996ca022f98a66fb9829c90ed5e8a3 Mon Sep 17 00:00:00 2001 From: Ryan Boren Date: Wed, 22 Apr 2009 17:45:20 +0000 Subject: [PATCH] Faster query to see if page has children git-svn-id: https://develop.svn.wordpress.org/trunk@11053 602fd350-edb4-49c9-b593-d223f7449a82 --- wp-includes/post-template.php | 6 ++---- 1 file changed, 2 insertions(+), 4 deletions(-) diff --git a/wp-includes/post-template.php b/wp-includes/post-template.php index 8e75c71b77..8317aa9a6d 100644 --- a/wp-includes/post-template.php +++ b/wp-includes/post-template.php @@ -362,7 +362,7 @@ function body_class( $class = '' ) { * @return array Array of classes. */ function get_body_class( $class = '' ) { - global $wp_query, $current_user; + global $wp_query, $wpdb, $current_user; $classes = array(); @@ -419,9 +419,7 @@ function get_body_class( $class = '' ) { setup_postdata($wp_query->post); $pageID = $wp_query->post->ID; - $page_children = wp_list_pages("child_of=$pageID&echo=0"); - - if ( $page_children ) + if ( $wpdb->get_var( $wpdb->prepare("SELECT ID FROM $wpdb->posts WHERE post_parent = %d AND post_type = 'page' LIMIT 1", $pageID) ) ) $classes[] = 'page-parent'; if ( $wp_query->post->post_parent )