Title: Adding Custom Google Search to header
Last modified: September 2, 2016

---

# Adding Custom Google Search to header

 *  [kevinknapp49](https://wordpress.org/support/users/kevinknapp49/)
 * (@kevinknapp49)
 * [9 years, 10 months ago](https://wordpress.org/support/topic/adding-custom-google-search-to-header/)
 * <?php include (‘[http://domain.com/wp-content/themes/themename/searchform.php&#8217](http://domain.com/wp-content/themes/themename/searchform.php&#8217););?
   >
    <?php echo do_shortcode(‘[wp_google_searchbox]’); ?>
 * Ive tried both these the top shows nothing the bottom prevents the page from 
   even loading.
 * The only thing in searchform.php is the copy+paste of the “get-code” from the
   custom search defined at the appropriate link.
 * I’ve set the id in the settings page as well even though im not planning on using
   the widget, I placed the widget in the sidebar for giggles and it works fine 
   there.
 * Not too sure what the issue is here.

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

 *  [Jasper](https://wordpress.org/support/users/lucydog/)
 * (@lucydog)
 * [9 years, 10 months ago](https://wordpress.org/support/topic/adding-custom-google-search-to-header/#post-8198615)
 * I have the same question and the same lack of success with the php code above…
   Trying to put the search form on my 404 page instead of the default search. Mine
   also works fine in the widget. Thank you!
 *  Thread Starter [kevinknapp49](https://wordpress.org/support/users/kevinknapp49/)
 * (@kevinknapp49)
 * [9 years, 10 months ago](https://wordpress.org/support/topic/adding-custom-google-search-to-header/#post-8198901)
 * I ended up having to create a widget area.
    This is in my Theme Functions.
 *     ```
       /**
        * Register Widget Area.
        *
        */
       function search_widget_init() {
   
       	register_sidebar( array(
       		'name' => 'Google Search',
       		'id' => 'google-search',
       	) );
       }
       add_action( 'widgets_init', 'search_widget_init' );
       ```
   
 * And this is in my header.
 *     ```
       <div id="search" class="col-lg-2 col-md-2 column">
       	<?php if ( is_active_sidebar( 'google-search' ) ) : ?>
       		<?php dynamic_sidebar( 'google-search' ); ?>
       	<?php endif; ?>
       </div>
       ```
   
 *  [Jasper](https://wordpress.org/support/users/lucydog/)
 * (@lucydog)
 * [9 years, 10 months ago](https://wordpress.org/support/topic/adding-custom-google-search-to-header/#post-8199537)
 * Thank you!
 *  Plugin Author [WebshopLogic](https://wordpress.org/support/users/webshoplogic/)
 * (@webshoplogic)
 * [9 years, 10 months ago](https://wordpress.org/support/topic/adding-custom-google-search-to-header/#post-8199858)
 * The second form of the first post have to be working if you insert it to a place
   where html body content can be displayed. This ‘place’ can be the post part or
   page header (but not the html head section, because it is outside of html body)
   or footer, or any sidebar or widget, …
 * `<?php echo do_shortcode('[wp_google_searchbox]'); ?>`
 * For example this code is display the search box at the beginning of every post,
   if you include this into your functions.php of your active theme:
 *     ```
       function the_content_wgs( $content ) {
       	$content = do_shortcode('[wp_google_searchbox]') . $content; 
       	return $content;
       }
       add_filter( 'the_content', 'the_content_wgs', 30, 1 );
       ```
   

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

The topic ‘Adding Custom Google Search to header’ is closed to new replies.

 * ![](https://ps.w.org/wp-google-search/assets/icon-256x256.png?rev=976021)
 * [WP Google Search](https://wordpress.org/plugins/wp-google-search/)
 * [Frequently Asked Questions](https://wordpress.org/plugins/wp-google-search/#faq)
 * [Support Threads](https://wordpress.org/support/plugin/wp-google-search/)
 * [Active Topics](https://wordpress.org/support/plugin/wp-google-search/active/)
 * [Unresolved Topics](https://wordpress.org/support/plugin/wp-google-search/unresolved/)
 * [Reviews](https://wordpress.org/support/plugin/wp-google-search/reviews/)

 * 4 replies
 * 3 participants
 * Last reply from: [WebshopLogic](https://wordpress.org/support/users/webshoplogic/)
 * Last activity: [9 years, 10 months ago](https://wordpress.org/support/topic/adding-custom-google-search-to-header/#post-8199858)
 * Status: not resolved