diff --git a/wp-includes/nav-menu.php b/wp-includes/nav-menu.php index a2f569596..68ca725a7 100644 --- a/wp-includes/nav-menu.php +++ b/wp-includes/nav-menu.php @@ -413,7 +413,8 @@ function wp_get_nav_menu_items( $menu, $args = array() ) { $items = get_objects_in_term( $menu->term_id, 'nav_menu' ); if ( ! empty( $items ) ) { - $defaults = array( 'order' => 'ASC', 'orderby' => 'menu_order', 'post_type' => 'nav_menu_item', 'post_status' => 'publish', 'output' => ARRAY_A, 'output_key' => 'menu_order', 'nopaging' => true ); + $defaults = array( 'order' => 'ASC', 'orderby' => 'menu_order', 'post_type' => 'nav_menu_item', 'post_status' => 'publish', 'output' => ARRAY_A, 'output_key' => 'menu_order', 'nopaging' => true, + 'update_post_term_cache' => false); $args = wp_parse_args( $args, $defaults ); if ( count( $items ) > 1 ) $args['include'] = implode( ',', $items ); diff --git a/wp-includes/post.php b/wp-includes/post.php index 450f8286e..1da5c9603 100644 --- a/wp-includes/post.php +++ b/wp-includes/post.php @@ -4003,9 +4003,11 @@ function clean_page_cache($id) { * @uses update_postmeta_cache() * * @param array $posts Array of Post objects - * @param string $post_type The post type of the posts in $posts + * @param string $post_type The post type of the posts in $posts. Default is 'post'. + * @param bool $update_term_cache Whether to update the term cache. Default is true. + * @param bool $update_meta_cache Whether to update the meta cache. Default is true. */ -function update_post_caches(&$posts, $post_type = 'post') { +function update_post_caches(&$posts, $post_type = 'post', $update_term_cache = true, $update_meta_cache = true) { // No point in doing all this work if we didn't match any posts. if ( !$posts ) return; @@ -4019,10 +4021,11 @@ function update_post_caches(&$posts, $post_type = 'post') { if ( empty($post_type) ) $post_type = 'post'; - if ( !is_array($post_type) && 'any' != $post_type ) + if ( !is_array($post_type) && 'any' != $post_type && $update_term_cache ) update_object_term_cache($post_ids, $post_type); - update_postmeta_cache($post_ids); + if ( $update_meta_cache ) + update_postmeta_cache($post_ids); } /** diff --git a/wp-includes/query.php b/wp-includes/query.php index 2a1615492..f08152512 100644 --- a/wp-includes/query.php +++ b/wp-includes/query.php @@ -1621,6 +1621,12 @@ class WP_Query { if ( !isset($q['cache_results']) ) $q['cache_results'] = true; + if ( !isset($q['update_post_term_cache']) ) + $q['update_post_term_cache'] = true; + + if ( !isset($q['update_post_meta_cache']) ) + $q['update_post_meta_cache'] = true; + if ( !isset($q['post_type']) ) { if ( $this->is_search ) $q['post_type'] = 'any'; @@ -2504,7 +2510,7 @@ class WP_Query { } if ( $q['cache_results'] ) - update_post_caches($this->posts, $post_type); + update_post_caches($this->posts, $post_type, $q['update_post_term_cache'], $q['update_post_meta_cache']); if ( $this->post_count > 0 ) { $this->post = $this->posts[0];