Take your website
To the next level
Discover our newly launched customization services and elevate your web projects to new heights.
Delegate tasks, save time, and unlock the power of professional WordPress outsourcing.

Okay
  Public Ticket #1463537
Custom menu in pages
Closed

Comments

  • prodisa started the conversation

    Hello, does the TheGem allow to set different menu in pages out of the box?

  •  7,092
    Oliver replied

    Hi,

    Here is the code example for settings up different menu on the different pages:

    function thegem_custom_wp_nav_menu_args($args) {
    if(in_array(get_the_ID(), array(555))) {
    if($args['theme_location'] == 'top_area') {
    $args['menu'] = 1000;
    }
    }
    if(in_array(get_the_ID(), array(666))) {
    if($args['theme_location'] == 'primary') {
    $args['menu'] = 1001;
    }
    }
    return $args;
    }
    add_filter('wp_nav_menu_args', 'thegem_custom_wp_nav_menu_args');
    555 and 666 page ID

    1000 and 1001 - menu ID

    555 and 666 page id.

    Add this code the the functions.php of the child theme

    Please note if you comment on your ticket before we reply, your ticket will be pushed down of the tickets list. 

    Regards, Oliver

  •  2
    jasonrae replied

    Will this code allow us to add menus in a page? or only at the top of the page where the normal menu belongs?  Thanks

  •  7,092
    Oliver replied

    Sorry, can't understand what you need to do...

    Please note if you comment on your ticket before we reply, your ticket will be pushed down of the tickets list. 

    Regards, Oliver

  • Giorgos replied

    Hello, I am having an issue  with the menu too when I try to make changes to the search form next to the main menu.

    Currently I click on the icon and the search form appears below. I want the search form always visible inline, next to the main menu. I attach an image that will help you understand what I want better.

    Regards

    Giorgos

  •  7,092
    Oliver replied

    Hi,

    Sorry, without the code changes it's not possible, it's not couple lines of the code, I can't make it for you free, we can help you in this request as individual paid support, let me know if you're interesting. 

    Please note if you comment on your ticket before we reply, your ticket will be pushed down of the tickets list. 

    Regards, Oliver

  • Giorgos replied

    Hi Gregor, I understand you cant do this for me. I just wanted to ask in which directory/file is the search form loaded from?

    I cant find it, the theme is huge. I will do the changes on my own.


    Thanks,

    Giorgos

  •  7,092
    Oliver replied

    Search form added via the action:

    function thegem_menu_item_search($items, $args){
        if($args->theme_location == 'primary' && thegem_get_option('header_layout') !== 'overlay'){
            $items .= '<li class="menu-item menu-item-search"><a href="#"></a><div class="minisearch"><form role="search" id="searchform" class="sf" action="'. esc_url( home_url( '/' ) ) .'" method="GET"><input id="searchform-input" class="sf-input" type="text" placeholder="'.esc_html__('Search...', 'thegem').'" name="s"><span class="sf-submit-icon"></span><input id="searchform-submit" class="sf-submit" type="submit" value=""></form></div></li>';
        }
        return $items;
    }
    add_filter('wp_nav_menu_items', 'thegem_menu_item_search', 10, 2);

    in the file:

    /wp-content/themes/thegem/functions.php

    line 2082

    You can remove this action in the child theme and add there with your code.

    Please note if you comment on your ticket before we reply, your ticket will be pushed down of the tickets list. 

    Regards, Oliver

  • Giorgos replied

    Thanks Gregor for the fast replies and your help!!!

    Regards from Greece,

    Giorgos

  •  7,092
    Oliver replied

    Feel free to contact us if you need help.

    Please note if you comment on your ticket before we reply, your ticket will be pushed down of the tickets list. 

    Regards, Oliver

  • Giorgos replied

    For anyone that might look for the same, I just erased these:

    menu-item-search & <a href="#"></a>

    and its working fine!!

  • prodisa replied

    Thank you for your answer Gregor.

    I could'nt work in my new site custom menus untill today, after I finished other customizations.

    I have altered your awesome example function to make it work with an array of pages with their custom menus.

    It would be great that the theme allows to manage the array values with custom fields in pages. I have no time to develop it right now, just letting you know an improvement proposal.

    function thegem_custom_wp_nav_menu_args($args) {
        $menus_wikiup = array(
            //Academias
            24904 => array(
                array(
                     'location' => 'primary',
                     'menu-id' => 100
                 )
            ), 
         );
        foreach($menus_wikiup as $page_id => $menus) {
            if(get_the_ID() == $page_id) {
                foreach($menus as $m) {
                    if($args['theme_location'] == $m['location']) {
                        $args['menu'] = $m['menu-id'];
                    }
                }
            }
        }
        return $args;
    }
    add_filter('wp_nav_menu_args', 'thegem_custom_wp_nav_menu_args');
    


  •  7,092
    Oliver replied

    Hi,

    Ok, we'll think about it.

    Please note if you comment on your ticket before we reply, your ticket will be pushed down of the tickets list. 

    Regards, Oliver