Community Forums › Forums › Archived Forums › Design Tips and Tricks › Add search bar in navigation bar
- This topic has 15 replies, 3 voices, and was last updated 8 years, 11 months ago by [email protected].
-
AuthorPosts
-
March 11, 2015 at 11:26 am #144048sellingonlinetodayMember
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 #144050Pixel FrauMemberYou 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 #144167sellingonlinetodayMemberHi 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 #144168Pixel FrauMemberDid 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 #144171sellingonlinetodayMemberHi,
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 #144173Pixel FrauMemberThat 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 #144174sellingonlinetodayMemberHi,
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 #144176Pixel FrauMemberThat looks correct. You re-saved / re-uploaded after removing the code snippet?
March 12, 2015 at 8:58 am #144177sellingonlinetodayMemberYes, 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 #144179sellingonlinetodayMemberI 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 #144180Pixel FrauMemberGreat. 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 #144182sellingonlinetodayMemberAgh 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 #144185Pixel FrauMemberYou 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 #144201sellingonlinetodayMemberHi 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 #144204Pixel FrauMemberSorry, 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]ParticipantI 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 -
AuthorPosts
- The forum ‘Design Tips and Tricks’ is closed to new topics and replies.