[Resolved] Move nav search icon to top bar

Home Forums Support [Resolved] Move nav search icon to top bar

Home Forums Support Move nav search icon to top bar

Viewing 12 posts - 1 through 12 (of 12 total)
  • Author
    Posts
  • #2318909
    George

    I have a GP element set as a top bar through the before_header hook and I want to move the nav search icon in there. Is there a way to do that, maybe through a shortcode?

    #2319490
    Fernando
    Customer Support
    #2319876
    George

    Ok thanks, that didn’t work for me, the search field not being visible but I decided to go with a search bar instead. I will reopen if needed.

    Thanks, Fernardo!

    #2320631
    Fernando
    Customer Support

    I see. You’re welcome George!

    #2326639
    George

    Hi Fernando, I came back to it and made it work. The only issue is that I can’t see the close search icon, any idea why? I am attaching a URL, check on mobile view.

    #2326646
    Fernando
    Customer Support

    Can you try creating a portable shortcode hook for the Search Icon? Example:

    function search_shortcode($atts, $content = null) {
          ob_start();
          do_action('hook_search');
          return ob_get_clean();
    }
    add_shortcode('portable_search', 'search_shortcode');
    
    add_action( 'wp', function() {
        if ( 'enable' === generate_get_option( 'nav_search' ) ) {
            remove_action( 'generate_menu_bar_items', 'generate_do_navigation_search_button' );
            add_action( 'hook_search', 'generate_do_navigation_search_button' );
    
            remove_action( 'generate_inside_navigation', 'generate_navigation_search' );
            add_action( 'hook_search', 'generate_navigation_search' );
        }
    }, 20 );

    With this, you can add shortcode portable_search anywhere.

    You can also create a new short code for generate_navigation_search so it’s in your preferred location.

    #2326650
    George

    Yeah, the previous code from Elvin from the thread you suggested produced the same result. The problem is the close button, somehow it gets hidden.

    #2326665
    Fernando
    Customer Support

    On desktop, did you set it to hide in the settings? It’s set to display: none on desktop.

    #2326667
    George

    Yeah, I am using the shortcode in a button which is only visible on mobile.

    #2326669
    Fernando
    Customer Support

    Can you try adding this CSS?:

    span.search-item.active.close-search a svg{
        fill: #000;
        z-index: 9999;
    }
    #2326963
    George

    Ah, perfect, thanks!

    #2327743
    Fernando
    Customer Support

    You’re welcome George!

Viewing 12 posts - 1 through 12 (of 12 total)
  • You must be logged in to reply to this topic.