How to Change Default WordPress Search to Google in Genesis

It’s easy to simply add your Google adsense for search code as a widget in your sidebar but when you want to place this search bar in certain positions, you may consider changing WordPress default search engine to Google. I redesigned this blog in the last few days, worked on the CSS, re-arranged the widgets and added some little tweaks here and there. I decided to place Google Adsense for search right there on the primary menu, floating to the right. It required a lot of coding I had no idea how to do and found Bill Erickson’s post on adding content to Genesis navigation. For some strange reasons, the code didn’t work for me when I tried adding Google custom search in that position.

Must Read: Adding Google Adsense to Genesis Without A plugin

I prefer Google Custom search to WordPress search for two reasons:

1. Your visitors get more relevant results
2. You have the chance to monetize your site even more

By going to Genesis > Theme Settings, you can easily display a search bar right there on your primary menu but only WordPress default search can be added in this position. It was then I thought  there should be a way to change that default search to Google Search so I could show custom search on the navigation menu. I messed around with the files in Genesis framework and eventually found it.

Must Read: How to Create your Own Custom WordPress Theme Easily

To do this, you must have created a Google custom search in your Adsense account and have the code ready. It would be great if you make the search result open a page in your site. You can create a page on your site (something like where search results would be displayed.

When creating this page, I think you should select the Full Width Content layout option. You may now login to your Adsense account and create your custom search engine, select the option to display search results on a page on your website, using that page you created. Also, You should only select only your website under site to search.

Got the code? Paste the one for your website on the page you created. Be sure you use HTML editor, not visual.

Must Read: 10 Tips to Reduce Excess CPU Usage on WordPress

Now, lets change WordPress default search to this Google Adsense search engine.

– Log in to cPanel and locate this file: …/public_html/wp-content/themes/genesis/lib/structure/search.php

– Download this file first in case something goes wrong or if you wish to revert back to WordPress default search later

– Using cPanel file editor, edit this file and scroll down till you see this piece of code:

<form method="get" class="searchform" action="' . home_url() . '/" >
' . $label . '
<input type="text" value="' . $search_text . '" name="s" class="s"' . $onfocus . $onblur . ' />
<input type="submit" class="searchsubmit" value="' . $button_text . '" />

– Replace this lines completely with your Adsense search code.

Now, anytime you use the search widget in your Genesis theme, it’s gonna be your Google custom search. To display the search engine like you see on my navigation bar:
– Log in to your WordPress dashboard and go to Genesis > Theme Settings. Under Navigation Settings, check the box that says Enable Extras on Right Side and select Search form.

This automatically places an Adsense for unit on your primary menu. Cool, huh?


According to a very valuable comment left by Patrik, the easiest way to this is by copying the Google custom search code to a text file, name it as searchform.php and upload to your child theme directory.

Filed Under: Wordpress

Author: Don Caprio

Don Caprio is a full time blogger / web designer living in Nigeria and apart from blogging, my other obsession is music. I'm a self-confessed Tupac fan, an iOS lover, an Android user, a Windows 8 power user, a writer with a 5-year old unfinished novel... and the list goes on and on. You can add me on Facebook, follow my updates on Twitter or add me to your circles on Google+! By the way, if your blog needs a custom design, you can contact me here...


  1. says

    I can see that you were editing the core framework file for this. This is absolutely not a good way to do this. When you update the framework, you’ll lose any customization made to the file. ps: I guess there is a plugin to do this. Try search in the WP plugin repository.

  2. says

    Whoops! Maybe I was wrong about the plugin. I didn’t notice that were talking about the Nav Extras! Sorry about that. But there’s a filter. Use filter instead of touching the core. Here’s a good tutorial to add your own code to the menu

  3. says

    Hi, I found an easier way of doing it, and without editing Genesis core framework. Make a file called searchform.php and upload it to your Genesis child theme. Paste in the Google custom search code. Genesis will handle the rest.

  4. says

    I just want to say BLESS YOU for this post! I tried the updated version but it didn’t work. When I went back and changed the code in my cPanel, as instructed early on in the post, it worked perfectly! I had already setup the default search box in the menu bar but, after changing the code, all I had to do was refresh the page and voila! My custom google search bar appeared. Thanks soooo much!

      • says

        Yes, unfortunately I updated WP and the changes were lost. Now when I try to do the same thing I did before, that worked, it doesn’t now. I think it’s because the code is in HTML5 now. Any suggestions?

        • says

          I haven’t had the chance to look at the files of the new Genesis version. If you still have the zip file for Genesis 1.9.2 or 1.8, unzip and upload the search.php script to your child theme folder. You can then edit as explained in this tutorial.

  5. raju ginne says

    but genesis 2.12 replacing search.php main frame work getting results new window of our website url (default google results page) not in our website with my website url.

Share Your Comments & Feedback:

Please do NOT use keywords in the name field because they won't be linked to anything anyway...just use your real name. Let's try to have a personal and meaningful conversation.

Commenting Note(s):
To insert code into comments, use: [php]code in here...[/php]
Some HTML tags allowed: <strong>, <em>, <del>, etc. (Just don't overdo it, please!)