• Skip to main content
  • Skip to forum navigation

StudioPress

  • Shop for Themes
  • My StudioPress

Forum navigation

  • Home
  • General Genesis Discussions
  • StudioPress Themes
  • Genesis Blocks
    • Genesis Blocks
    • Genesis Custom Blocks
  • Retired Themes
  • FAQs
  • Forum Rules
  • Internationalization and Translations
  • Forum Bugs and Suggestions
  • Forum Log In

Are You Using The WordPress Block Editor?

Genesis now offers plugins that help you build better sites faster with the WordPress block editor (Gutenberg). Try the feature-rich free versions of each plugin for yourself!

Genesis Blocks Genesis Custom Blocks

Adding Search to Nav Bar

Welcome!

These forums are for general discussion on WordPress and Genesis. Official support for StudioPress themes is offered exclusively at My StudioPress. Responses in this forum are not guaranteed. Please note that this forum will require a new username, separate from the one used for My.StudioPress.

Log In
Register Lost Password

Community Forums › Forums › Archived Forums › Design Tips and Tricks › Adding Search to Nav Bar

This topic is: resolved

Tagged: nav menu, search feature

  • This topic has 6 replies, 2 voices, and was last updated 10 years, 8 months ago by EmLY14.
Viewing 7 posts - 1 through 7 (of 7 total)
  • Author
    Posts
  • December 7, 2015 at 8:00 am #172931
    EmLY14
    Member

    Is it possible to add a search feature to the primary navigation menu in Cafe Pro? Thanks in advance.

    December 7, 2015 at 8:12 am #172932
    Brad Dalton
    Participant

    Try the Genesis Nav Menu extras


    Tutorials for StudioPress Themes.

    December 7, 2015 at 9:05 am #172958
    EmLY14
    Member

    Thank you @braddalton but this didn't work when I added the code to my functions folder.

    December 7, 2015 at 9:59 am #172967
    Brad Dalton
    Participant

    As of Genesis 2.1, the Primary Navigation Extras options have been removed for new installs. (upgrades of current installs to 2.1 will not lose the Primary Navigation Extras settings). If you are running a new install and want to add a the date or a search form to a navigation menu, use the following code. (see comments for further instruction)

    You'll need to uncomment part of the code to enable the search function like this.

    //* Uncomment this block to add a search form to the navigation menu
    
    	ob_start();
    	get_search_form();
    	$search = ob_get_clean();
    	$menu  .= '<li class="right search">' . $search . '';
    
    

    Tutorials for StudioPress Themes.

    December 7, 2015 at 10:43 am #172993
    EmLY14
    Member

    I am running Version: 2.2.3

    Just to confirm I need to add all of the code including the Uncomment piece into the functions folder -

    add_filter( 'wp_nav_menu_items', 'theme_menu_extras', 10, 2 );
    /**
    * Filter menu items, appending either a search form or today's date.
    *
    * @param string $menu HTML string of list items.
    * @param stdClass $args Menu arguments.
    *
    * @return string Amended HTML string of list items.
    */
    function theme_menu_extras( $menu, $args ) {
    //* Change 'primary' to 'secondary' to add extras to the secondary navigation menu
    if ( 'primary' !== $args->theme_location )
    return $menu;
    //* Uncomment this block to add a search form to the navigation menu
    /*
    ob_start();
    get_search_form();
    $search = ob_get_clean();
    $menu .= '<li class="right search">' . $search . '';
    */
    return $menu;

    December 7, 2015 at 10:52 am #172995
    Brad Dalton
    Participant

    Using a code editor, add the following to your functions file


    Tutorials for StudioPress Themes.

    December 7, 2015 at 11:16 am #173008
    EmLY14
    Member

    Thank you for your help @braddalton, all sorted 🙂

  • Author
    Posts
Viewing 7 posts - 1 through 7 (of 7 total)
  • The topic ‘Adding Search to Nav Bar’ is closed to new replies.

CTA

Ready to get started? Create a site or shop for themes.

Create a site with WP EngineShop for Themes

Footer

StudioPress

© 2026 WPEngine, Inc.

Products
  • Create a Site with WP Engine
  • Shop for Themes
  • Theme Features
  • Get Started
  • Showcase
Company
  • Brand Assets
  • Terms of Service
  • Accptable Usse Policy
  • Privacy Policy
  • Refund Policy
  • Contact Us
Community
  • Find Developers
  • Forums
  • Facebook Group
  • #GenesisWP
  • Showcase
Resources
  • StudioPress Blog
  • Help & Documentation
  • FAQs
  • Code Snippets
  • Affiliates
Connect
  • StudioPress Live
  • StudioPress FM
  • Facebook
  • Twitter
  • Dribbble