Ask your WordPress questions! Pay money and get answers fast! Comodo Trusted Site Seal
Official PayPal Seal

Use deafult WordPress/Genesis Search Box For Google Custom Search WordPress


Need to use the default wp search box or the Genesis secondary nav menu extras box as the search box for Google custom search rather than the WordPress/Genesis search function.

Answers (1)


Daniel Yoen answers:

Try this :

add_filter( 'genesis_search_form', 'cse_search_form', 10, 4);
function cse_search_form()
{ ?>

<!-- Search Code From Google -->

<?php } ?>

Hope this help :-)

Brad Dalton comments:

All this code?

(function() {
var cx = '016091704148407788467:gdnr4qsprcm';
var gcse = document.createElement('script');
gcse.type = 'text/javascript';
gcse.async = true;
gcse.src = (document.location.protocol == 'https:' ? 'https:' : 'http:') +
'//' + cx;
var s = document.getElementsByTagName('script')[0];
s.parentNode.insertBefore(gcse, s);

Daniel Yoen comments:

Yes, All :-)

Brad Dalton comments:

I do want to use the default search box, NOT the Google search box styling. Only the Google search function.

Brad Dalton comments:

It displays full width twice in I.E and uses the Google custom search styling.

Displays the correct width in FF but still double with Google styling.

It outputs in the correct location which is good but still needs some work.

Brad Dalton comments:

Daniel Yoen comments:

Sorry, remove that function, you need this :

<div id="cse" style="width: 100%;">Loading</div>
<script src="" type="text/javascript"></script>
<script type="text/javascript">
function parseQueryFromUrl () {
var queryParamName = "q";
var search =;
var parts = search.split('&');
for (var i = 0; i < parts.length; i++) {
var keyvaluepair = parts[i].split('=');
if (decodeURIComponent(keyvaluepair[0]) == queryParamName) {
return decodeURIComponent(keyvaluepair[1].replace(/\+/g, ' '));
return '';

google.load('search', '1', {language : 'en', style : google.loader.themes.MINIMALIST});
google.setOnLoadCallback(function() {
var customSearchControl = new'YourKey');

var options = new;
customSearchControl.draw('cse', options);
var queryFromUrl = parseQueryFromUrl();
if (queryFromUrl) {
}, true);

Put this line to loop in search.php


<?php while ( have_posts() ) : the_post(); ?>


<?php endwhile; ?>

Hope this help :-)

Daniel Yoen comments:

Don't forget to replace "YourKey" with your own key from google :-)

Brad Dalton comments:

This is the code from the Genesis parent theme:

WARNING: This file is part of the core Genesis framework. DO NOT edit
this file under any circumstances. Please do all modifications
in the form of a child theme.

* This file handles the search results page.
* This file is a core Genesis file and should not be edited.
* @category Genesis
* @package Templates
* @author StudioPress
* @license GPL-2.0+
* @link

add_action( 'genesis_before_loop', 'genesis_do_search_title' );
* Echo the title with the search term.
* @since 1.9.0
function genesis_do_search_title() {

$title = sprintf( '<h1 class="archive-title">%s %s</h1>', apply_filters( 'genesis_search_title_text', __( 'Search Results for:', 'genesis' ) ), get_search_query() );

echo apply_filters( 'genesis_search_title_output', $title ) . "\n";



//Which search.php file where you referring to? There is no search.php in the child theme.

Daniel Yoen comments:

Sorry, for genesis is a bit tricky, you can follow step by step here :

hope this help :-)