Support Forums

Looking for support? You can access the support system via your account.

Forums Forums Search & Filter Pro Add searchform to menu

Viewing 6 posts - 1 through 6 (of 6 total)
  • Miriam Brückner
    #232271

    Hi there – I added a regular search box to my menu and now am wondering if there is a way to replace this by a s&f pro search form? And if possible which is the easiest way to do so? Using a shortcode?

    Trevor Moderator
    #232322

    There are three ways:

    1. Add a shortcode.
    2. Change the HTML of the search already in the menu to send to a Search & Filter results/search page.
    3. Use a WordPress re-write to send to a Search & Filter results/search page.

    Which do you think would be best for you?

    Miriam Brückner
    #232358

    I do think option 2 or 3!?? Even so with some assistance I think I can accomplish all of them…

    Trevor Moderator
    #232362

    OK, the easiest and least resource using is #2. How did you add the original search to the menu?

    Miriam Brückner
    #232621

    This is the code in my child theme’s function.php that I added to add the search form:

    add_theme_support( ‘html5’, array( ‘search-form’ ) );
    add_filter(‘wp_nav_menu_items’, ‘add_search_form_to_menu’, 10, 2);
    function add_search_form_to_menu($items, $args) {
    // If this isn’t the main navbar menu, do nothing
    if( !($args->theme_location == ‘main’) ) // with Customizr Pro 1.2+ and Cusomizr 3.4+ you can chose to display the saerch box to the secondary menu, just replacing ‘main’ with ‘secondary’
    return $items;
    // On main menu: put styling around search and append it to the menu items
    return $items . ‘<li class=”my-nav-menu-search”>’ . get_search_form(false) . ‘‘;
    }

    Trevor Moderator
    #232695

    Ah. That we cannot use, I think.

    Are you able to send me a live link/URL to a page with the search in the menu so I can take a look?

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

You must be logged in to reply to this topic.