WordPress.org

Ready to get started?Download WordPress

Forums

[resolved] Adding the searchform to the navbar (5 posts)

  1. Taragon
    Member
    Posted 4 years ago #

    Hello,

    I hope it would be ok to ask this question right away, before properly introducing myself as a first-time poster :)

    I'm currently trying to implement a search form within my twentyten navbar.

    This is what I'm hoping to accomplish:

    <div class="menu-header" id="menu-menu-1">
    	<ul class="menu">
    		<li class="menu-item menu-item-type-  menu-item-object- current-menu-item" id="menu-item-4"><a>About</a></li>
    		<li>...</li>
    		<form id="searchform" name="searchform" method="get" action="<?php echo home_url(); ?>">
    		<div id="search">
    			<input type="text" id="s" name="s" />
    			<input type="submit" id="searchsubmit" value="<?php esc_attr_e( 'Search', 'twentyten' ); ?>" />
    		</div>
    		</form><!-- #end the bit I'm trying to add -->
    	</ul>
    </div>

    Currently I have:

    <div id="access">
    				<div class="skip-link screen-reader-text"><a href="#content" title="<?php esc_attr_e( 'Skip to content', 'twentyten' ); ?>"><?php _e( 'Skip to content', 'twentyten' ); ?></a></div>
    				<?php wp_nav_menu( array( 'sort_column' => 'menu_order', 'container_class' => 'menu-header' ) ) ; ?>
    			</div><!-- #access -->

    and

    <form id="searchform" name="searchform" method="get" action="<?php echo home_url(); ?>">
    		<div>
    			<label for="s"><?php _e( 'Search', 'twentyten' ); ?></label>
    			<input type="text" id="s" name="s" />
    			<input type="submit" id="searchsubmit" value="<?php esc_attr_e( 'Search', 'twentyten' ); ?>" />
    		</div>
        </form>

    not really sure what to do next.

  2. annedorko
    Member
    Posted 4 years ago #

    You'll need to customize the following and make sure that the functions are correct (I'm just writing this from memory so my exact syntax may be off):

    <ul class="menu-header">
        <?php wp_list_pages(); ?>
        <li class="search"><?php get_search_form(); ?></li>
    </ul>

    wp_list_pages() can be customized to pull in info as you need.

  3. Taragon
    Member
    Posted 4 years ago #

    Thanks Anne, that fixed the issue. Didn't knew wp worked this way. Much appreciating your help!

  4. annedorko
    Member
    Posted 4 years ago #

    You're welcome! Happy WPing :)

  5. iistudios
    Member
    Posted 3 years ago #

    Sorry if I'm changing the op but I'm looking to add the rss button and twitter button to the menu is the code similar or should I approach it differently?

Topic Closed

This topic has been closed to new replies.

About this Topic