Forums

How can I add the search to the header? (4 posts)

  1. Unit9
    Member
    Posted 5 years ago #

    Knowing little about PHP, I tried adding this code to my header:

    <?php
    function wp_widget_search($args) {
    extract($args);
    ?>
    <?php echo $before_widget; ?>
    <form id="searchform" method="get" action="<?php bloginfo('home'); ?>">
    <div>
    <input type="text" name="s" id="s" size="15" />
    <input type="submit" value="<?php echo attribute_escape(__('Search')); ?>" />
    </div>
    </form>
    <?php echo $after_widget; ?>
    <?php
    }
    ?>

    And probably unsurprisingly I got a fatal error. :)

    Can anyone tell me how to add the search functionality to somewhere other then the sidebar?

  2. Jeremy Clark
    Moderator
    Posted 5 years ago #

    Don't double post. All you need to add is this code.

    <form method="get" id="searchform" action="<?php bloginfo('url'); ?>/">
    <div><input type="text" value="<?php the_search_query(); ?>" name="s" id="s" />
    <input type="submit" id="searchsubmit" value="Search" />
    </div>
    </form>
  3. Unit9
    Member
    Posted 5 years ago #

    Thanks Jeremy and sorry - won't do it again - just realised I posted in the wrong forum! :)

  4. jamesspratt
    Member
    Posted 4 years ago #

    @jeremyclark13 - thanks

Topic Closed

This topic has been closed to new replies.

About this Topic

Tags

No tags yet.