+321 123 4567
info@test.com
  • Home
  • My Services
    • Web Design
    • Web Development
    • Technical Writing
  • Portfolio
  • My Thoughts
  • Free Tools
    • Photo Editor
    • Avatar Generator
    • Email Migration Tool
    • QR Code Generator
    • RSS to HTML Converter
    • IP Address Geolocation
    • Base64 Image Encoder
    • NATO Translator
    • All Tools
  • Contact
Home
Wordpress
How to Change Default WordPress Search to Google in Genesis

How to Change Default WordPress Search to Google in Genesis

Wale Adekile
November 22, 2012

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 www.doncaprio.com/search) 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 . '" />
</form>

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

Update<

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.


Previous Post
How To Fix Missing Song Info (Album Art, Artist & Album Names)
Next Post
Fix: Missing BigBoss, ModMyi & ZodTTD Repo in Cydia
Wale Adekile
Husband to the world's most beautiful woman and father to two awesome kids. A nerd, obviously; also, a technical business analyst, a web designer who preaches the gospel of WordPress, and a writer. You can check out my published books on Amazon.
sharethis
Social MediaWordpress

5 Best Social Sharing Plugins for WordPress

12 years ago
facebook comment box for genesis
Wordpress

Adding Facebook Comment to Genesis Without a Plugin

12 years ago

Recent Articles

wahl rapic clip hair clipper
Wahl Rapid Clip Hair Clipper Review: DIY Made Easy
BenQ LaptopBar Review: Luxury or Necessity?
yunmai easepro unboxed
Yunmai EasePro Massage Gun Review
g20
Teendow G20 Robot Vacuum and Mop Review
bathroom
Dear Men, Spraying All Over the Toilet Seat is Disgusting and Irresponsible
winx mediatrans
How to Transfer Photos from iPhone to Computer Without iTunes
google workspace
How to Migrate Emails From Google Workspace/G Suite to cPanel
synology diskstation ds920+
Synology DiskStation DS920+ Review
playstation 4
Why I haven’t Upgraded to the PlayStation 5 Yet
pain
Started Watching Anime as an Adult? You’re Not Alone

All contents on this blog are copyright protected and cannot be reproduced on other websites without permission.

Copyright © 2022 – NerdieDad | Home | Contact | About | Privacy Policy