[wp-trac] [WordPress Trac] #28159: get_body_class makes a raw, uncacheable query for child posts

WordPress Trac noreply at wordpress.org
Wed May 7 02:25:05 UTC 2014


#28159: get_body_class makes a raw, uncacheable query for child posts
--------------------------+-----------------------------
 Reporter:  rmccue        |      Owner:
     Type:  defect (bug)  |     Status:  new
 Priority:  normal        |  Milestone:  Awaiting Review
Component:  Themes        |    Version:
 Severity:  normal        |   Keywords:
  Focuses:                |
--------------------------+-----------------------------
 `get_body_class()` calls `$wpdb->get_var( $wpdb->prepare("SELECT ID FROM
 $wpdb->posts WHERE post_parent = %d AND post_type = 'page' AND post_status
 = 'publish' LIMIT 1", $page_id) )` just so it can add a single class.

 It also accesses the database directly this way, and is hence not
 cacheable at all, causing a query to be made on every page for something
 that's not always needed (but can't be disabled).

--
Ticket URL: <https://core.trac.wordpress.org/ticket/28159>
WordPress Trac <https://core.trac.wordpress.org/>
WordPress publishing platform


More information about the wp-trac mailing list