0

I am developing a theme of my own. In functions.php I added -

add_action( 'init', 'register_my_menus' ); 

function register_my_menus() { register_nav_menus( array(

         'front_login_menu' => _( 'front_login_menu location'),
         'top_front_general_menu' => _( 'top_front_general_menu'),
         'top_general_menu' => _( 'top_general_menu'),
         'top_student_menu' => _( 'top_student_menu'),
         'top_admin_menu' => _( 'top_admin_menu'), 
         'top_trainer_menu' => _( 'top_trainer_menu' ) ) ); }

Then I created the custom menus in the admin panel. But suddenly I found that those menus except one are not visible in the right side of the Appearance -> Menus page in online server but the theme locations do exist. But those menus are visible in my localhost. I was supposed to create them (some if not all) in online server too.

If I want to create one of those missing menus then the message says:

The menu name .... conflicts with another menu name. Please try another.

How can I get those menu names appear in the right side of the theme locations?

2
  • Try a very basic check, copy the menu name and in your editor try to find (typically Ctrl + F) the same keyword exist somewhere else. If so, dissolve the conflict. For function name try something different than register_my_menus. And moreover try debugging turned on into your WP installation. Oct 6, 2013 at 13:17
  • @MayeenulIslam, I changed all the menu names and theme locations. The problem is when I create a menu after another one the previous menu disappears so I cannot add any menu item to the previous one. How to get rid of this situation ? Oct 6, 2013 at 13:40

1 Answer 1

2

I don't think you need to initiate the menus again where register_nav_menus() itself is an initiator.

Syntax: <?php register_nav_menu( 'your-menu-handle', 'Your Menu Label' ); ?>

Copy the following code and Paste them into your functions.php without any function or add_action(), I hope it'll work:

register_nav_menus(
    array(
     'front_login_menu' => __( 'Front Login Menu location'),
     'top_front_general_menu' => __( 'Top Front General Menu'),
     'top_general_menu' => __( 'Top General Menu'),
     'top_student_menu' => __( 'Top Student Menu'),
     'top_admin_menu' => __( 'Top Admin Menu'), 
     'top_trainer_menu' => __( 'Top Trainer Menu' )
    )
);

Use the following code into your theme, where you want to show the menu:

<?php wp_nav_menu (
            array (
                'theme_location'=>'front_login_menu', //change the slug here where necessary
                'fallback_cb'=>''
            )
        ); ?>
3
  • did not solve the question. The online server has prob in its mysql DB. Thinking whether it is related with that, Oct 6, 2013 at 14:35
  • How the menu codes are connected with your db prob - I'm thinking of that too. Ok, I did a minor edit with a double underscore (__()) instead of single underscore (_()). (know why) Oct 6, 2013 at 14:43
  • 1
    When the Browse tab of the Db table was clicked, it showed error. This problem was solved and the menu names also appeared in place. Oct 10, 2013 at 7:15

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.