Make the WordPress search button appear after the search box

The following tutorial explains how to make the WordPress search button appear after the search box in your sidebar. If your like me, you’d probably rather have the search button next to the search box rather than under the search box. However, by default, the sidebar widget employs a break between the search form and search button. This is relatively easy to fix as I explain below.

Making the WordPress search button appear next to the search box:

  1. Using an ftp client, navigate to your WordPress wp-includes directory and locate the widgets.php file
  2. Using a text or code editor, open the widgets.php file and find the following code:

    <?php echo $before_widget; ?>
    <form id=”searchform” method=”get” action=”<?php bloginfo(‘home’); ?>”>
    <div>
    <input type=”text” name=”s” id=”s” size=”15″ /><br />
    <input type=”submit” value=”<?php echo attribute_escape(__(‘Search’)); ?>” />
    </div>
    </form>

  3. Remove the break in the code so it looks like the following:

    <?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>

  4. upload the fixed wigets.php to your wp-includes directory replacing the original.
  5. Correcting the CSS to allow the search form and button to fit on the same line:

  6. Login to your WordPress admin panel and navigate to Design -> Theme Editor. From the Theme Editor, select (Stylesheet) Style.css
  7. Find the following section of code:

    #sidebar #searchform #s {
    width: 108px;
    padding: 2px;
    }

  8. Change the code to the following:

    #sidebar #searchform #s {
    width: 90px;
    padding: 1px;
    }

  9. Were basically just changing the width of the searchform to allow the searchform and searchsubmit to appear on one line.

  10. Click Update File and go view your site 🙂