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.


  1. Nwosu Desmond says:

    This is indeed awesome as it has helped my change the default search on my blog to a Google search. Thanks for this resourceful information/

  2. this nice don but would like to know how to intergrate it just like your witth adsence

  3. Good post, although am not using genesis but i usually have problem with the wordpress comment system. the genesis users need this more

  4. I used a much different and simple method on my genesis child theme Nice share though

  5. This one of the post I have seen in a long time. I will certainly bookmark your post

  6. Nice article. This is the right time i start making some bucks from adsense for search

  7. Woooow This is great. How i wish adsense will just let me for once. Will try this

  8. says:

    Another great one from you sir, Was resourceful.

  9. 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.

  10. 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

    • You’re right, Rudd. I did link to the article in the post above and even recommend it but I couldn’t make it work. I lost the customized search form when I upgraded to Genesis 1.9.1 and had to repeat the steps.

  11. 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.

  12. Mohammed Abdullah Khan says:

    I’m trying to add Google custom search instead of normal search form. When I replaced the code with my code it shows error. Any solutions ?

  13. 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!

    • Don Caprio says:

      Great, John! Glad it worked for you but note that the changes gets lost when a new version of Genesis comes out.

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

        • Don Caprio 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.

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!)