• 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

Want to align a search box in a menu

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 › Want to align a search box in a menu

This topic is: not resolved

Tagged: align menu, search box

  • This topic has 3 replies, 2 voices, and was last updated 9 years ago by David Borrink.
Viewing 4 posts - 1 through 4 (of 4 total)
  • Author
    Posts
  • February 20, 2017 at 1:00 pm #201663
    David Borrink
    Participant

    I added a function to put a search box in my menu and want it inline with my menu items.

    //* add search box to end of menu
    add_filter( 'wp_nav_menu_items', 'theme_menu_extras', 10, 2 );
    function theme_menu_extras( $menu, $args ) {
    
    	if ( 'primary' !== $args->theme_location )
    		return $menu;
    
    	ob_start();
    	get_search_form();
    	$search = ob_get_clean();
    	$menu  .= '<li class="search menu-item">' . $search . '</li>';
    
    	return $menu;
    
    }

    This is being done in Genesis-Sample.

    I gave it a li class of menu-item so that it would appear in my line of menu items. It appears to the right of the menu items, but slightly higher in position. About 3 pixels above the height of the other menu items. I want to bring it down to line up with the text of my menus. I add a margin-top of 6px and the item moves down 6px from the top line of the menu, but not closer aligned to the menu items. Those items move further downward from the top of the menu area.

    I'm trying justify-content, align-items, and other things and whatever I do, the menu items are not aligning horizontally.

    Any ideas?

    http://staging1.davidandsallie.com/
    February 20, 2017 at 1:05 pm #201665
    Victor Font
    Moderator

    Just reposition it. You already have a class for .nav-primary .search at line 1216 in style.css. Use that move the search box down:

    .nav-primary .search {
        position: relative;
        top: 18px;
    }

    Regards,

    Victor
    https://victorfont.com/
    Call us toll free: 844-VIC-FONT (842-3668)
    Have you requested your free website audit yet?

    February 20, 2017 at 2:01 pm #201667
    David Borrink
    Participant

    Victor, Thank you for pointing me in the right direction. I had not considered "position: relative". That did it. Thank you!

    February 20, 2017 at 2:16 pm #201670
    David Borrink
    Participant

    There's one more thing now. Suddenly when I hover over the search box, it shifts up to where it was. Move out, and it goes back. I added a hover state to the CSS, and that took care of it.

    .nav-primary .search, .nav-primary .search:hover {
        position: relative;
        top: 20px;
        }
  • Author
    Posts
Viewing 4 posts - 1 through 4 (of 4 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