Title: Widget breaks search
Last modified: August 19, 2016

---

# Widget breaks search

 *  [Philljc](https://wordpress.org/support/users/philljc/)
 * (@philljc)
 * [15 years, 2 months ago](https://wordpress.org/support/topic/widget-breaks-search/)
 * Hello, here’s the code I’m using.
 *     ```
       <?php
       $searchtext = get_search_query();
       if($searchtext == ''){ $searchtext = 'Search...'; }
       ?>
       <div id="search"><form method="get" id="searchform" action="<?php bloginfo('url'); ?>/">
         <div>
           <input type="text" value="<?php echo $searchtext; ?>" name="s" id="searchfield" onfocus="if (this.value==this.defaultValue) this.value='';" />
           <input type="image" src="wp-content/themes/active/images/go.jpg" id="searchsubmit" value="Search" />
         </div>
       </form></div>
   
       <div class="sidedivider"></div>
       ```
   
 * When I put it in the sidebar.php file, it works fine. When I copy the same block
   to a new Widget (via the text option, then pasting it in) the search completely
   breaks.
 * Is this because I’m putting PHP in one of these? Is there a way to fix it?
 * Thanks.

Viewing 2 replies - 1 through 2 (of 2 total)

 *  [tanira](https://wordpress.org/support/users/tanira/)
 * (@tanira)
 * [15 years, 2 months ago](https://wordpress.org/support/topic/widget-breaks-search/#post-1950523)
 * try adding the widget “search” on the sidebar instead of a widget “text”, then
   you can create an searchform.php file on your theme and put your code on it.
 *  Thread Starter [Philljc](https://wordpress.org/support/users/philljc/)
 * (@philljc)
 * [15 years, 2 months ago](https://wordpress.org/support/topic/widget-breaks-search/#post-1950693)
 * That fixes the search and kind of defeats the purpose of having it as a custom
   widget, and there are other PHP widgets I need to use

Viewing 2 replies - 1 through 2 (of 2 total)

The topic ‘Widget breaks search’ is closed to new replies.

 * In: [Fixing WordPress](https://wordpress.org/support/forum/how-to-and-troubleshooting/)
 * 2 replies
 * 2 participants
 * Last reply from: [Philljc](https://wordpress.org/support/users/philljc/)
 * Last activity: [15 years, 2 months ago](https://wordpress.org/support/topic/widget-breaks-search/#post-1950693)
 * Status: not resolved

## Topics

### Topics with no replies

### Non-support topics

### Resolved topics

### Unresolved topics

### All topics
