wp admin - Menus not visible in Appearance after being registered

admin2025-01-08  4

The menus have been registered in functions.php, but they don't appear within the Appearance > Menus section in Admin and the pages, posts etc options are greyed out.

The menus are saved, as you can not create the menu with the same name again.

Within functions.php:

function theme_setup() {
    add_theme_support( 'automatic-feed-links' );
    add_theme_support( 'post-thumbnails' );
    add_theme_support( 'html5', array( 'search-form' ) );
    /*** Register Menus */
    if (function_exists('register_nav_menus'))
    {
        register_nav_menus(
        array(
            'main-menu'         => __( 'Main Menu', 'site' ),
            'footer-menu'       => __( 'Footer Menu', 'site' ),
            )
        );
    }
}
add_action('after_setup_theme', 'theme_setup');

Within header.php

wp_nav_menu(
                array(
                    'menu'          => 'Main Menu',
                    'container'     => '',
                    'depth'         => 1,
                    'theme_location' => 'main-menu',
                )
            );

Within footer.php

wp_nav_menu(
                array(
                    'menu'          => 'Footer Menu',
                    'container'     => '',
                    'items_wrap'    => '',
                    'theme_location' => 'footer-menu'
                )
            );

The main issue here is that these menus exist and are rendering out on the site, but they seem to be hidden within the admin panel and if a new menu is created it never shows up.

Using Wordpress version 4.7 (Latest)

Plugins:

What could be causing this?

The menus have been registered in functions.php, but they don't appear within the Appearance > Menus section in Admin and the pages, posts etc options are greyed out.

The menus are saved, as you can not create the menu with the same name again.

Within functions.php:

function theme_setup() {
    add_theme_support( 'automatic-feed-links' );
    add_theme_support( 'post-thumbnails' );
    add_theme_support( 'html5', array( 'search-form' ) );
    /*** Register Menus */
    if (function_exists('register_nav_menus'))
    {
        register_nav_menus(
        array(
            'main-menu'         => __( 'Main Menu', 'site' ),
            'footer-menu'       => __( 'Footer Menu', 'site' ),
            )
        );
    }
}
add_action('after_setup_theme', 'theme_setup');

Within header.php

wp_nav_menu(
                array(
                    'menu'          => 'Main Menu',
                    'container'     => '',
                    'depth'         => 1,
                    'theme_location' => 'main-menu',
                )
            );

Within footer.php

wp_nav_menu(
                array(
                    'menu'          => 'Footer Menu',
                    'container'     => '',
                    'items_wrap'    => '',
                    'theme_location' => 'footer-menu'
                )
            );

The main issue here is that these menus exist and are rendering out on the site, but they seem to be hidden within the admin panel and if a new menu is created it never shows up.

Using Wordpress version 4.7 (Latest)

Plugins:

What could be causing this?

Share Improve this question edited Jan 6, 2017 at 12:30 mixchex asked Jan 6, 2017 at 10:00 mixchexmixchex 11 silver badge3 bronze badges
Add a comment  | 

2 Answers 2

Reset to default 0

There's nothing wrong with your theme_setup() function in your functions.php file.

The error you get simply points out the fact that the menu name Main Menu already exists.

In other to resolve this you should replace your Main Menu menu name definitions in your functions.php file with something other than what it currently is.

It's possible you might be using a theme or a plugin which already has a menu name registered as such, accounting for the current menu name conflict.


Update:

Your code works well. I think your challenge has to do with registered menu location vs actual menu (form the dashboard, as actual menus to be rendered into a given registered menu location).

What you should do: type inside the "Menu Name" input box as seen on you first shared screenshot a new menu name, then, click on the "Create Menu" button; your custom registered menu locations will then be visible as seen in the screenshot below:

UPDATE:

The issue was caused by the WPCoreSys plugin. Not sure of its purpose.

Something which was in the plugin had a conflict and stopped the menu editor from working.

The plugin was not visible within the Plugins section, but it was present within the file directory. As it was not active, it was removed and now the menu area functions as expected.

转载请注明原文地址:http://conceptsofalgorithm.com/Algorithm/1736268845a1306.html

最新回复(0)