Need to append custom menu

Home Forums ColorMag Free Need to append custom menu

This topic contains 14 replies, has 2 voices, and was last updated by  ashishsthanp 1 week ago.

Viewing 15 posts - 1 through 15 (of 15 total)
  • Author
    Posts
  • #1323605

    fabio
    Participant

    Hi,

    I have setup my Colormag child theme and I have also customized header.php.
    Now I need to apend a custom menu to the Primary menu (only under certain conditions), so to have something like:

    wp_nav_menu( array( 'theme_location' => 'primary', 'container_class' => 'menu-primary-container', 'items_wrap'      => '<ul id="%1$s" class="%2$s">%3$s</ul>' ) );
    
    if (condition==true) {
      wp_nav_menu(array('menu' => 'my-custom-menu'));
      }

    But it is not working, as it is simply duplicating the primary menu, showing it twice. I have created my-custom-menu in WP admin backend, from the Menu page.

    #1323660

    ashishsthanp
    Moderator

    @fabio

    Have you registered your custom menu like this?

    	register_nav_menus(array(
    		'my-custom-menu' => __( 'My Custom Menu', 'colormag' )
    	));

    and menu item to that menu from the dashboard.

    Thanks.

    #1323712

    fabio
    Participant

    Of course. I first created the menu in the menu editor from the dashboard. Then, in functions php I have added:

    add_action( 'after_setup_theme', 'register_my_menu' );
    function register_my_menu() {
      register_nav_menu( 'my-custom-menu',  'My Custom menu' );
    }

    and in header php:

    wp_nav_menu( array( 'theme_location' => 'primary', 'container_class' => 'menu-primary-container', 'items_wrap'      => '<ul id="%1$s" class="%2$s">%3$s</ul>' ) );
    wp_nav_menu(array('menu' => 'my-custom-menu'));

    But the menu is not showing appended to the primary menu. Is not showing at all. I also have this error in the apache error.log:

    [Wed Sep 06 10:28:23.788931 2017] [:error] [pid 3185] [client 109.115.214.43:56218] PHP Notice: Undefined variable: image_alt in /var/www/ibaa/wp-content/themes/colormag/inc/widgets/widgets.php on line 1017

    • This reply was modified 2 weeks ago by  fabio.
    #1323791

    ashishsthanp
    Moderator

    Hello, @fabio

    Can you provide us URL of your website so that we can inspect it and give you a proper solution?

    Regards,
    ThemeGrill Support Team.

    #1323829

    fabio
    Participant
    This reply has been marked as private.
    #1323925

    ashishsthanp
    Moderator

    @fabio

    It seems you’ve not used the child theme of our theme in your site.

    Can you do the same as you mentioned in your query and come back to us so that we can check the issue properly.

    Thanks.

    #1323954

    fabio
    Participant
    This reply has been marked as private.
    #1324191

    fabio
    Participant

    Did you get it?

    #1324253

    ashishsthanp
    Moderator

    Hello, @fabio

    There’s might be some misconfiguration on your dashboard area which we could not figure out from your site.

    Could you provide the temporary login access to your site so that we could find the issue and provide an appropriate solution?

    Also, do not forget to Set reply as private while posting with login details.

    Regards,
    ThemeGrill Support Team.

    #1324296

    fabio
    Participant
    This reply has been marked as private.
    #1324304

    fabio
    Participant
    This reply has been marked as private.
    #1324397

    ashishsthanp
    Moderator

    @fabio

    Go to header.php file in your child theme and replace
    wp_nav_menu(array('menu' => 'provola'));
    with
    wp_nav_menu(array('theme_location' => 'provola'));

    Thanks.

    #1324399

    ashishsthanp
    Moderator

    @fabio

    Go to header.php file in your child theme and replace
    wp_nav_menu(array('menu' => 'provola'));
    with
    wp_nav_menu(array('theme_location' => 'provola'));

    Thanks.

    #1324436

    fabio
    Participant

    Did it, but nothing changes. Still have the main menu displayed twice and that error in apache…

    #1324570

    ashishsthanp
    Moderator

    @fabio
    The issue has come from your child theme and we could not figure it out.

    Can you revert back the code you’ve added for creating menu and follow this article for adding custom menu.
    https://premium.wpmudev.org/blog/add-menus-to-wordpress/

    For the Apache issue, check if it comes after switching to our theme.

    Thanks.

Viewing 15 posts - 1 through 15 (of 15 total)

You must be logged in to reply to this topic.