Some optimizations for wp_nav_menu
-
Hi,
Doing a performance review of our web-site and noticed that dependent functions of wp_nav_menu collects the full content (and a bunch of other stuff) of all pages.
This patch enables one to only collect the information that’s necessary to generate the menus without collecting unnecessary data.
I would request that these gets added upstream.
*** a/wp-includes/post.php2011-03-07 22:02:59.000000000 +0100
— b/wp-includes/post.php2011-04-05 15:00:55.000000000 +0200
***************
*** 1354,1359 ****
— 1354,1360 —-$r[‘ignore_sticky_posts’] = true;
$r[‘no_found_rows’] = true;
+ $r[‘fields’] = ‘menu_items’;$get_posts = new WP_Query;
return $get_posts->query($r);*** a/live.op5.com/wp-includes/query.php2011-03-07 22:02:59.000000000 +0100
— b/wp-includes/query.php2011-04-05 14:34:16.000000000 +0200
***************
*** 1978,1983 ****
— 1978,1986 —-
case ‘id=>parent’:
$fields = “$wpdb->posts.ID, $wpdb->posts.post_parent”;
break;
+ case ‘menu_items’:
+ $fields = “$wpdb->posts.ID, $wpdb->posts.post_title, $wpdb->posts.post_excerpt, $wpdb->posts.post_status, $wpdb->posts.menu_order, $wpdb->posts.post_type”;
+ break;
default:
$fields = “$wpdb->posts.*”;
}
- The topic ‘Some optimizations for wp_nav_menu’ is closed to new replies.