Title: Adding Menu on Category Pages
Last modified: September 1, 2016

---

# Adding Menu on Category Pages

 *  Resolved [matthieu14](https://wordpress.org/support/users/matthieu14/)
 * (@matthieu14)
 * [9 years, 9 months ago](https://wordpress.org/support/topic/adding-menu-on-category-pages/)
 * Hello all !
 * I have been using Customizr theme for a while and it is really amazing. I would
   like first to thank the developers who made it possible and affordable for anyone:).
 * Quick question, I found out that the menus (both header & footer) are not appearing
   on my category pages while it is appearing on single pages and single posts.
 * Is it possible with a simple snippet to add them also to category pages ?
 * [Here is a link](http://www.okumak.fr/category/niveau-4/) to one of the categories
   of my website where you can see that the menus both in the header & footer are
   not appearing.
 * Thank you in advance for anyone who will help,
    Best, Matthieu

Viewing 9 replies - 1 through 9 (of 9 total)

 *  [Menaka S.](https://wordpress.org/support/users/menakas/)
 * (@menakas)
 * [9 years, 9 months ago](https://wordpress.org/support/topic/adding-menu-on-category-pages/#post-7632282)
 * Hi,
    I find that the menu is displayed in some categories like [Cours de truc](http://www.okumak.fr/category/cours-de-turc/).
 * Have you done any customization of category pages?
 *  Thread Starter [matthieu14](https://wordpress.org/support/users/matthieu14/)
 * (@matthieu14)
 * [9 years, 9 months ago](https://wordpress.org/support/topic/adding-menu-on-category-pages/#post-7632328)
 * Hello Menaka S,
 * Thanks for your answer.
 * You are right, the menu is displayed in some categories like the one you have
   quoted ! But I have no customized category page.
 * Yet, I think we have a clearer picture of the problem now : the menu is not displayed
   only on “sub-category” pages. Indeed, on categories like [Cours de turc](http://www.okumak.fr/category/cours-de-turc)
   or [Themes](http://www.okumak.fr/category/pratiquer/themes/), the menu is displayed
   but in categories included into other categories such as [Niveau 1](http://www.okumak.fr/category/cours-de-turc/niveau-1/)
   which belongs to Cours de turc, the menu is not displayed.
 * How can we fix that ?
 * Thank you in advance !
 *  [Menaka S.](https://wordpress.org/support/users/menakas/)
 * (@menakas)
 * [9 years, 9 months ago](https://wordpress.org/support/topic/adding-menu-on-category-pages/#post-7632431)
 * Hi,
    1. Have you altered the query in any way? 2. Can you try disabling all plugins
   and then check?
 *  Thread Starter [matthieu14](https://wordpress.org/support/users/matthieu14/)
 * (@matthieu14)
 * [9 years, 9 months ago](https://wordpress.org/support/topic/adding-menu-on-category-pages/#post-7632440)
 * Hello Menaka,
 * 1. Yes I have altered the query for this kind of pages using the following snippet:
 *     ```
       add_action('pre_get_posts','alter_query');
       function alter_query($query) {
       	//gets the global query var object
       	if (is_category('niveau-1')==false and is_category('niveau-2')==false and is_category('niveau-3')==false and is_category('niveau-4')==false and is_category('niveau-5')==false and is_category('niveau-6')==false)
       		return;
   
       	$query-> set('orderby' ,'meta_value_num');
           $query-> set('meta_key','ordon');
           $query-> set('order','ASC');
       }
       ```
   
 * The idea is to order the posts of these subcategories by a meta-key called “ordon”.
   Is it possible that it makes the menu disappear?
 * 2. I tried to disable all of them, it does not change anything
 *  [Menaka S.](https://wordpress.org/support/users/menakas/)
 * (@menakas)
 * [9 years, 9 months ago](https://wordpress.org/support/topic/adding-menu-on-category-pages/#post-7632473)
 * Hi,
    Can you try commenting 1)the if condition 2)the entire alter query to check
   if the problem is caused by this code?
 *  Thread Starter [matthieu14](https://wordpress.org/support/users/matthieu14/)
 * (@matthieu14)
 * [9 years, 9 months ago](https://wordpress.org/support/topic/adding-menu-on-category-pages/#post-7632512)
 * Hello Menaka,
 * Sorry for responding late, I was off for a few days.
 * Here are my comments :
 * > add_action(‘pre_get_posts’,’alter_query’);
   >  function alter_query($query) { //
   > if the pages do not belong to the category “niveau-1”, “niveau-2” up to “niveau-
   > 6”, do nothing if (is_category(‘niveau-1’)==false and is_category(‘niveau-2’)
   > ==false and is_category(‘niveau-3’)==false and is_category(‘niveau-4’)==false
   > and is_category(‘niveau-5’)==false and is_category(‘niveau-6’)==false) return;//
   > if the page belongs to one of the aforementionned categories do the following//
   > modify the query by ordering the posts by a meta_key called “ordon” that I 
   > have created for the posts belonging to the aforementionned categories. // 
   > and order by an ascending order $query-> set(‘orderby’ ,’meta_value_num’); 
   > $query-> set(‘meta_key’,’ordon’); $query-> set(‘order’,’ASC’); }
 * It is likely that this query is causing the problem since the menu is not displayed
   only for the categories concerned by the if condition..
 * Is it clearer ?
    Thanks in advance,
 * M.
 *  [Menaka S.](https://wordpress.org/support/users/menakas/)
 * (@menakas)
 * [9 years, 9 months ago](https://wordpress.org/support/topic/adding-menu-on-category-pages/#post-7632519)
 * Hi,
    Nav menus are also generated by a WP_Query, so in your pre_get_posts callback
   function you need to check if the $query you’re altering is the main query.
 * Please add this to the beginning of your alter_query() function.
 *     ```
       if ( ! $query->is_main_query() )
           return $query;
       ```
   
 *  Thread Starter [matthieu14](https://wordpress.org/support/users/matthieu14/)
 * (@matthieu14)
 * [9 years, 9 months ago](https://wordpress.org/support/topic/adding-menu-on-category-pages/#post-7632520)
 * Thanks a lot Menaka, it is solved !
 *  [Menaka S.](https://wordpress.org/support/users/menakas/)
 * (@menakas)
 * [9 years, 8 months ago](https://wordpress.org/support/topic/adding-menu-on-category-pages/#post-7632523)
 * Glad 🙂

Viewing 9 replies - 1 through 9 (of 9 total)

The topic ‘Adding Menu on Category Pages’ is closed to new replies.

 * ![](https://i0.wp.com/themes.svn.wordpress.org/customizr/4.4.24/screenshot.png)
 * Customizr
 * [Support Threads](https://wordpress.org/support/theme/customizr/)
 * [Active Topics](https://wordpress.org/support/theme/customizr/active/)
 * [Unresolved Topics](https://wordpress.org/support/theme/customizr/unresolved/)
 * [Reviews](https://wordpress.org/support/theme/customizr/reviews/)

## Tags

 * [category page](https://wordpress.org/support/topic-tag/category-page/)
 * [disappear](https://wordpress.org/support/topic-tag/disappear/)
 * [menu](https://wordpress.org/support/topic-tag/menu/)

 * 9 replies
 * 2 participants
 * Last reply from: [Menaka S.](https://wordpress.org/support/users/menakas/)
 * Last activity: [9 years, 8 months ago](https://wordpress.org/support/topic/adding-menu-on-category-pages/#post-7632523)
 * Status: resolved