• 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

Add search bar in navigation 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 › Add search bar in navigation bar

This topic is: not resolved

Tagged: bar, navigatio, search

  • This topic has 15 replies, 3 voices, and was last updated 11 years, 2 months ago by [email protected].
Viewing 16 posts - 1 through 16 (of 16 total)
  • Author
    Posts
  • March 11, 2015 at 11:26 am #144048
    sellingonlinetoday
    Member

    Hi, i'm looking to add a search bar into my navigation bar, beside the current tabs. If anyone could lend me a hand to complete this i appreciate it

    Theme: genesis framework sample

    Ill help you out as much as possible, so any questions please ask

    http://www.sellingonlinetoday.com/about/
    March 11, 2015 at 11:35 am #144050
    Pixel Frau
    Member

    You should be able to do that with the Genesis Nav Extras. They were included in former versions of Genesis, but have since been removed for new installs.

    Check your Genesis Settings for Navigation options. If there's no Navigation section, follow these instructions to add the nav extras. Then select Search form from the dropdown menu.

    March 12, 2015 at 8:41 am #144167
    sellingonlinetoday
    Member

    Hi Pixel,
    I had added in this code and it has completely messed up my site, it now doesnt display and comes up with the error >>> "Parse error: syntax error, unexpected end of file in /home/sellingonline123/public_html/wp-content/themes/genesis-sample/functions.php on line 68"

    I removed the code and the same error came up again. Check out the error here http://www.sellingonlinetoday.com/category/podcast-interviews/

    Thanks

    March 12, 2015 at 8:43 am #144168
    Pixel Frau
    Member

    Did you add the first two lines by mistake?

    <?php
    //* Do NOT include the opening php tag

    Or perhaps you missed the closing bracket at the very end of the code snippet?

    March 12, 2015 at 8:46 am #144171
    sellingonlinetoday
    Member

    Hi,
    Thanks for the reply, although i didn't copy in the php code that was instructed to be left out.

    This is the last bit of code in the box >

    "
    //* Add support for 3-column footer widgets
    add_theme_support( 'genesis-footer-widgets', 3 );

    "

    Am i missing something from the end?

    March 12, 2015 at 8:48 am #144173
    Pixel Frau
    Member

    That section is correct, but it's not part of the nav options code you added.

    If you copy/paste your functions.php I'll take a look. Use the code button when pasting to retain the formatting.

    March 12, 2015 at 8:50 am #144174
    sellingonlinetoday
    Member

    Hi,
    I removed the code that i had previously entered as i thought that was the error, its supposed to be like it was before i put in the code.

    <?php
    //* Start the engine
    include_once( get_template_directory() . '/lib/init.php' );

    //* Child theme (do not remove)
    define( 'CHILD_THEME_NAME', 'Genesis Sample Theme' );
    define( 'CHILD_THEME_URL', 'http://www.studiopress.com/' );
    define( 'CHILD_THEME_VERSION', '2.1.2' );

    //* Enqueue Google Fonts
    add_action( 'wp_enqueue_scripts', 'genesis_sample_google_fonts' );
    function genesis_sample_google_fonts() {

    wp_enqueue_style( 'google-fonts', '//fonts.googleapis.com/css?family=Lato:300,400,700', array(), CHILD_THEME_VERSION );

    }

    //* Add HTML5 markup structure
    add_theme_support( 'html5', array( 'search-form', 'comment-form', 'comment-list' ) );

    //* Add viewport meta tag for mobile browsers
    add_theme_support( 'genesis-responsive-viewport' );

    //* Add support for custom background
    add_theme_support( 'custom-background' );

    //* Add support for 3-column footer widgets
    add_theme_support( 'genesis-footer-widgets', 3 );

    March 12, 2015 at 8:56 am #144176
    Pixel Frau
    Member

    That looks correct. You re-saved / re-uploaded after removing the code snippet?

    March 12, 2015 at 8:58 am #144177
    sellingonlinetoday
    Member

    Yes, correct, i have re-saved the code after removing the 'new' code. I also had a copy in a notepad file, copy and pasted that and it still comes up an error aswell

    March 12, 2015 at 9:01 am #144179
    sellingonlinetoday
    Member

    I saw you mentioned 're-upload' so i went to my cpanel and downloaded the functions file and saw the 'new' code was still in it, so i re-uploaded the working code and all works now.

    March 12, 2015 at 9:03 am #144180
    Pixel Frau
    Member

    Great. The StudioPress code snippet for adding the nav extras definitely works. Just make sure you copy/paste correctly. The most common mistakes are accidentally including the first two lines or missing the last closing bracket.

    March 12, 2015 at 9:10 am #144182
    sellingonlinetoday
    Member

    Agh i cant seem to get it working correctly, can you assist me? Can you remove what needs to be removed so it can work showing the search bar? I tried again but simply got another error on a different line. >>

    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 . '';
    */

    //* Uncomment this block to add the date to the navigation menu
    /*
    $menu .= '<li class="right date">' . date_i18n( get_option( 'date_format' ) ) . '';
    */

    return $menu;
    }

    March 12, 2015 at 9:14 am #144185
    Pixel Frau
    Member

    You need to use the code button when pasting code on the forum, otherwise some of the HTML is stripped.

    Here's the full functions.php with the nav extras:

    <?php
    //* Start the engine
    include_once( get_template_directory() . '/lib/init.php' );
    
    //* Child theme (do not remove)
    define( 'CHILD_THEME_NAME', 'Genesis Sample Theme' );
    define( 'CHILD_THEME_URL', 'http://www.studiopress.com/' );
    define( 'CHILD_THEME_VERSION', '2.1.0' );
    
    //* Enqueue Google Fonts
    add_action( 'wp_enqueue_scripts', 'genesis_sample_google_fonts' );
    function genesis_sample_google_fonts() {
    
    	wp_enqueue_style( 'google-fonts', '//fonts.googleapis.com/css?family=Lato:300,400,700', array(), CHILD_THEME_VERSION );
    
    }
    
    //* Add HTML5 markup structure
    add_theme_support( 'html5', array( 'search-form', 'comment-form', 'comment-list' ) );
    
    //* Add viewport meta tag for mobile browsers
    add_theme_support( 'genesis-responsive-viewport' );
    
    //* Add support for custom background
    add_theme_support( 'custom-background' );
    
    //* Add support for 3-column footer widgets
    add_theme_support( 'genesis-footer-widgets', 3 );
    
    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 . '</li>';
    	*/
    
    	//* Uncomment this block to add the date to the navigation menu
    	/*
    	$menu .= '<li class="right date">' . date_i18n( get_option( 'date_format' ) ) . '</li>';
    	*/
    
    	return $menu;
    
    }
    March 12, 2015 at 10:19 am #144201
    sellingonlinetoday
    Member

    Hi again,
    This doesn't seem to work, I've pasted the code into the functions, don't think it's meant to be!

    March 12, 2015 at 10:37 am #144204
    Pixel Frau
    Member

    Sorry, I'm not able to help more without seeing your actual theme files. The StudioPress code snippet works perfectly for me on a fresh install of the Genesis Sample Theme.

    April 9, 2015 at 9:47 am #147222
    [email protected]
    Participant

    I am using Parallax Pro -- I have tried everything but I cannot place a search box in my main navigation. I can add a search into the menu as a widget but it still appears below the menu :/ Would you be able to help?

    my website: http://www.nicesweethot.com

    Best regards,
    Jacek

  • Author
    Posts
Viewing 16 posts - 1 through 16 (of 16 total)
  • The forum ‘Design Tips and Tricks’ is closed to new topics and 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