0

I recently began experimenting with WordPress Multisite and I'm running into an issue with the primary navigation menu. Instead of showing the items in the menu that's registered as the primary menu, it just lists around 20 pages.

I'm using the same theme as the master site on the network and I've copied some of the tables (posts, terms, and most options) from the master site. The tables were copied directly in MySQL and not through a plugin.

This is the code I'm using in the header to insert the main nav menu and it works on the master site:

<?php wp_nav_menu( array(
    'theme_location' => 'main_nav_primary',
    'container'      => false,
    'menu_class'     => 'main-nav__primary__list loading'
) ); ?>

The menu is registered in functions.php, and I've added the menu as the primary menu in the theme locations.

I looked in my options table for relevant options and listed them below. There may be more options I didn't find with my query.

+-----------+-------------------------------+-------------------------------------+----------+
| option_id | option_name                   | option_value                        | autoload |
+-----------+-------------------------------+-------------------------------------+----------+
|       103 | widget_nav_menu               | a:1:{s:12:"_multiwidget";i:1;}      | yes      |
|       485 | nav_menu_options              | a:2:{i:0;b:0;s:8:"auto_add";a:0:{}} | yes      |
|      4016 | wp-optimize-enable-admin-menu | false                               | no       |
+-----------+-------------------------------+-------------------------------------+----------+

Do multisite menus have to be configured differently? I've set up my network to use sub-domains, also.

4
  • A couple of guesses- behind the scenes, menus are built with a nav_menu taxonomy and nav_menu_item post type, maybe you've broken some associations between those objects and the actual posts/pages they reference when you copied the tables over. The other guess is maybe the query for your menu items is getting hijacked by some improperly targeted code, like a query filter or pre_get_posts action.
    – Milo
    Dec 29, 2016 at 17:35
  • @Milo It may have been useful for me to mention in the question, but when I copied over the menus, the primary nav menu was the only one that didn't copy over. I had to recreate it manually. Does that sound like a broken association? I'll take a look at those tables to see if I can find anything.
    – mcon
    Dec 29, 2016 at 17:44
  • another thing to check is what you have set for fallback_cb argument of wp_nav_menu. it's possible it is failing to find the menu and is outputting a list of posts as a fallback.
    – Milo
    Dec 29, 2016 at 17:47
  • @Milo fallback_cb wasn't specified and was defaulting to those pages. I guess now I just have to figure out why that menu isn't being found.
    – mcon
    Dec 29, 2016 at 17:55

1 Answer 1

0

Thanks to help from @Milo, I was able to figure it out. It had to do with the 'theme_location' => 'main_nav_primary' line in the wp_nav_menu function call in the header. In functions.php, the primary menu was just registered as primary so I had to change the function call to 'theme_location' => 'primary'.

I find it odd that the master site still served the correct menu with this discrepancy, but I'm going to assume there is some option or filter that made that happen and try to figure out which.

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service and acknowledge that you have read and understand our privacy policy and code of conduct.

Not the answer you're looking for? Browse other questions tagged or ask your own question.