• 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

Searchform as 1st item on left of navmenu

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 › Searchform as 1st item on left of navmenu

This topic is: not resolved

Tagged: menu

  • This topic has 1 reply, 2 voices, and was last updated 12 years, 3 months ago by SoZo.
Viewing 2 posts - 1 through 2 (of 2 total)
  • Author
    Posts
  • December 3, 2012 at 3:01 pm #3126
    sanjoyroy
    Member

    I am using Prose theme. I would like to add a searchform as the first item on the left of the primary navmenu. I found this helpful article from Bill Erickson (http://www.billerickson.net/genesis-wordpress-nav-menu-content/) on adding custom content to the navmenu on the right hand side. I tried it out with a searchform, reversing the final concatenation to get the custom content (in this case, the searchform) to appear on before the rest of the menu instead of after it.

    The searchform does appear, but before the navmenu div rather than inside it. Is there a way of getting it inside the navmenu as the first item?

    My custom navmenu filter/function (adapted from Bill Erickson's) is:

    /* Searchbox in menu */

    add_filter( 'genesis_nav_items', 'sr_menu_searchform', 10, 2 );

    add_filter( 'wp_nav_menu_items', 'sr_menu_searchform', 10, 2 );

    function sr_menu_searchform($menu, $args) {

    $args = (array)$args;

    if ( 'primary' !== $args['theme_location'] )

    return $menu;

    $searchform = '<li id="search">' . get_search_form() . '</li>' ;

    return $searchform . $menu;

    }

     

    My html output is:

    <form method="get" action="http://localhost:8888/" >

    <input type="text" value="Search this website &hellip;" name="s" onfocus="if (this.value == 'Search this website &hellip;') {this.value = '';}" onblur="if (this.value == '') {this.value = 'Search this website &hellip;';}" />

    <input type="submit" value="Search" />

    </form>

    <div id="nav"><div><ul id="menu-primary-menu"><li id="search"></li><li id="menu-item-5438"><a href="http://localhost:8888/">Home</a></li>

    <li id="menu-item-5439"><a href="http://localhost:8888/faq/">FAQ</a></li>

    [...etc. for other list items in menu...]

    </ul></div>

     

    Thanks!

     

    January 25, 2013 at 1:27 pm #14696
    SoZo
    Member

    Enable the search form in navigation extras in the Genesis settings and then change the floats. I recommend installing the Firebug add on for Firefox or using Chrome's Firebug Lite which will enable you to right click on any element to inspect it and determine the associated style rules or the selectors required to create new style rules.


    John “Nicolas Flamel” Wright | SoZo’s design| John Wright Photography

  • Author
    Posts
Viewing 2 posts - 1 through 2 (of 2 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

© 2025 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