ThemeShaper Forums » Thematic

[closed]

Putting a search box in the menu

(5 posts)
  • Started 4 years ago by neonbible
  • Latest reply from neonbible
  • This topic is resolved

Tags:

  1. neonbible
    Member

    Using WP 3.0 custom menu with Thematic 0.9.7.4. Can it be done?

    I can add an 'item' to the menu using:

    function child_add_menu_items($output) {
        $my_search='</ul></div>';
        $my_replecement = '<li>Hello World!!</li></ul></div>';
        return str_replace($my_search, $my_replecement, $output);
        }    
    
    add_filter('wp_nav_menu','child_add_menu_items');

    however not sure how to put a search box in there.

    Thanks

    Posted 4 years ago #
  2. I had this code lying around, haven't tested or checked in a while but perhaps it still works if you replace wp_page_menu for wp_nav_menu:

    //  Add a dynamic menu using wp_list_pages
    
    function childtheme_menu() { ?>
         <div class="menu">
    
              <ul class="sf-menu">
                    <?php wp_list_pages('title_li='); ?>
              </ul>
    
                        <div id="access-search">
                    <form id="searchform" method="get" action="<?php bloginfo('home') ?>">
                        <div>
                            <input id="s" name="s" type="text" value="Search" onfocus="if (this.value == 'Search InMobi') {this.value = '';}" onblur="if (this.value == '') {this.value = 'Search InMobi';}" size="20" tabindex="1" />
                            <input id="searchsubmit" name="searchsubmit" type="submit" value="<?php _e('Go', 'thematic') ?>" tabindex="2" />
                        </div>
                    </form
    
                ></div>
    
         </div>
    
    <?php }
    
    add_action('wp_page_menu','childtheme_menu');
    Posted 4 years ago #
  3. neonbible
    Member

    I tried this before. It added the search box but then the rest of the menu disappeared.

    EDIT: Sorry, this works perfectly!! Awesome thank you!

    EDIT2: Ok its not working perfectly. Its added the Search box, in the correct position. But the menu has gone back to the default despite specifying wp_nav_menu

    Posted 4 years ago #
  4. neonbible
    Member

    I am thinking I could shrink the width of the menu and add in another div next to it to hold the search box.

    Whats the best way to do this? I guess add something into functions.php but I don't know what I would hook it into.

    Posted 4 years ago #
  5. neonbible
    Member

    Had to shorten the menu width and add another div in the end.

    Posted 4 years ago #

RSS feed for this topic

Topic Closed

This topic has been closed to new replies.