Hi, I’m having the same problem for a few weeks now. I’m glad I found this blog, because I was totally lost. My primary menu shows perfect with page.php and single.php but it doesn’t work with category.php
I’m trying to implement jian118 solution but I can’t image how am I gonna make getMainMenu()? cause wp_nav_menu() prints directly and I can’t get a return value to evaluate true or false. I know that probably I have the solution in front of me but I can’t see it.
I have issues finding the solution to this problem because I really don’t know why it is happening.
I found this post by Ronald Huereca: https://weblogtoolscollection.com/archives/2008/04/19/paging-and-custom-wordpress-loops.
It explains why pagination doesn’t work on category.php. He says that next_posts_link and previous_posts_link functions, as well as several others, make use of a global variable called $wp_query. This variable is actually an instance of the WP_Query object. However, when we create our own instantiation of WP_Query, we don’t have this global variable $wp_query, which is why paging will not work.
I think that could be a good explanation if only I could understand how $wp_query works, when it is instantiated, and why is it that when the category.php calls the header.php the menu doesn’t work, or wp_query is not ready.
I posted this commentary just to ask for some help for make getMainMenu(), sorry if just made a lot of questions. Thanks.