My theme need to render 2 menus in homepage. The rest pages only need one. As result is only homepage got duplicate query warning. After tracking down, I found out this was cause by
wp_nav_menu. How do I avoid this problem?
SELECT t.*, tt.* FROM wp_terms AS t INNER JOIN wp_term_taxonomy AS tt ON t.term_id = tt.term_id WHERE t.term_id = 163
And its caller:
According to debugger, potential troublemakers are
get_term_field. However, I can be very sure that I don't directly use them. It must be called from the
wp_nav_menu is the main suspect because in other page, such as archive page or singular page, I couldn't find any duplication warning.
Is this the core bug? Anyway, how do I avoid it? My theme has been slow recently (up to 0.30s~0.60s rendering time for homepage) so I would like to optimize it very much.
Sorry, I forgot to share my menu info. I actually has 3 menu locations and 2 of them are placed in homepage. At homepage I use
wp_nav_menu 2 times.
I register those in
register_nav_menus([ 'menu_col' => __('Menu Column', 'lucidy'), 'menu_list' => __('Menu List', 'lucidy'), 'menu_bar' => __('Menu Bar', 'lucidy') ]);