Site logo

Archived topic

add search button to logged-in members' navigation menu

19 replies · Started by Pierre-Marie on September 19, 2020

Viewing posts 16–20 of 20

Ok try adding this PHP snippet to your site:

add_filter( 'wp_nav_menu_items', function( $nav, $args ) {
    if ( $args->theme_location == 'members-primary' ) {
        return $nav . '<li class="search-item" title="' . esc_attr_x( 'Search', 'submit button', 'generatepress' ) . '"><a href="#"><span class="screen-reader-text">' . _x( 'Search', 'submit button', 'generatepress' ) . '</span></a></li>';
    }

    return $nav;
}, 10, 2 );

This article explains adding PHP:
https://docs.generatepress.com/article/adding-php/

Thanks David but Code Snippets signals an error on the last line of the code.
Red cross in front of } 10, 2 );
Is there something missing? Or should I still go ahead like this?

Worked perfectly, thanks!

Phew... i wasn't sure it would - so i am super glad to hear it does !

This archived topic is closed to new replies.