Site logo

Archived topic

Link Primary Navigation, Navigation Search to another page?

26 replies · Started by Carsten on January 1, 2021

Viewing posts 1–15 of 27

Hi there, I like the search option in the Primary Navigation, but the WP Search is of no use on my site.

Is it possible to link the Navigation Search to another page link, instead of the general WP search form?

Thanks!

Hi Carsten,

Not quite sure if I fully understand.

Can you explain a bit more?

Typically the navigation search option in GP can only be used as the default search function.

Hi Leo, as you wrote the navigation search option in GP can only be used as the default search function.

This search function does not cover any of my BuddyPress member content, and therefore is useless on my site.

Instead I have a search link, domain/search/ in the secondary menu, but I like to have the search option in the header, next to the menu instead.

https://imgur.com/YzyLTHm

So what I'm looking for is an option and suggestion in settings to be able to link Navigation Search to a link like this instead: mydomain/search/

Hope this clarifies

Regards

This search function does not cover any of my BuddyPress member content, and therefore is useless on my site.

Hmm I wonder why that is - does the search widget from WordPress work for that?

No, and my search is based on a special BP search plugin which is only based on BP members x-profile fields.

So the Navigation Search need in my case to link to domain/search

If you just want it to link to a page, turn off the Nav search option and use this hook: https://docs.generatepress.com/article/generate_menu_bar_items/

add_action( 'generate_menu_bar_items', function() {
    ?>
        <span class="menu-bar-item">
            <a href="#your-page-URL"><?php echo generate_do_svg_icon( 'search' ); ?></a>
        </span>
    <?php
} );

Hi there, thanks for the code, I have added it to a hook element, but it breaks the site, should i add anything else to make it work?

add_action( 'generate_menu_bar_items', function() {
    ?>
        <span class="menu-bar-item">
            <a href="#mydomain/search"><?php echo generate_do_svg_icon( 'search' ); ?></a>
        </span>
    <?php
} );

Thanks!

Hi Leo, thanks for providing both solutions for adding the code, it's working perfectly.

I must say I'm impressed what this theme has to offer, with it's endlessly options

Thanks again!

No problem :)

Hi there, the svg_icon html magnifier is defined by 'search'

I want to hook other items to my menu bar, and want to have a svg_icon for a Message link. Where do I find the right html for an message icon to use in this code?

<span class="menu-bar-item">
    <a href="/members/me/messages/"><?php echo generate_do_svg_icon( '  ' ); ?>
		<span class="count"><?php echo bp_get_total_unread_messages_count( bp_loggedin_user_id() );?></span></a>
</span>

I want only my login link in my menu bar, on the frontpage. So far I have excluded my Primary navigation from the frontpage by disabling it in a layout element.

But if I use this method, my the login item in my menu bar element is also disabled. How do I solve this, so only my Login element is visible on my Frontpage for logged out users, and my Primary Menu and my other Menu Bar Items are displayed for logged in users on all pages, than the Frontpage?

Thanks!

To do that, you would need to:

a) Hide your menu items will CSS instead of removing them completely.
b) Include a completely separate element with your icons/links.

To add a link with another icon, you would need to find the image (an SVG ideally) and add it to the link.

Hi there, I might instead be able to use another hook than generate_menu_bar_itemsfor the Login, which is not affected by the Primary Navigation Layout Element, which still is positioned in the header?

To add a link with another icon, you would need to find the image (an SVG ideally) and add it to the link.

To my understanding, the word 'search' is in this case representing an SVG of a magnifier.

But if I change this to email, message, profile or other names of SVG icons, it won't work?
So how do I find the name of the corresponding SVG? Arrow works as well, but nothing else?

Thank you

Hi there,

GP only loads SVGs that are used by the theme, such as the Search Icon, Hamburger Menu, Toggle Arrows and that is it. If you want a custom SVG you would need to create it or source it from one of the many icon libraries available on the web.

Hi there, thanks for the clarification.

If I look in the GP theme file fontawesome-webfont.svg, I can see a lot of svg webfonts listed, among them an envelope <glyph glyph-name="envelope" unicode="" horiz-adv-x="1792"
but it is not available like you said.

Do you have any documentation on how to use or activate more svg icons than the ones used by the theme?

Thanks

This archived topic is closed to new replies.