• Home
  • About

Snippet IT

IT News, Programming, Internet and Blogging

  • Programming and Scripting
  • Tips and Tricks
  • Software and Hardware
  • New and Happening
You are here: Home / Programming and Scripting / Google Adsense Search Result in Worpress

Google Adsense Search Result in Worpress

April 18, 2008 by Sze Hau Leave a Comment

Those who have Google Adsense account and WordPress may want to add Google Adsense Search function to his or her WordPress blog. Besides the search functionality from Google to search the pages within your site and Internet, you also can earn money from the Adsense advertisement within the Google Search result.

There are a few approaches you can add a Google Search function into your WordPress, but at here, I will show you the approach I am using and I think it is the easiest one.

Step 1 – Get Ready with Google Search code

Login to your Google Adsense account. Click on "Adsense Setup" and then "Adsense for Search". Apply your own style, and under "Opening of search result page", make sure you have chosen "Open results within my own site". Type in the page URL on your WordPress blog that you want to show the search result (e.g. www.snippetit.com/search) under the "Enter URL where search results will be displayed" and also type in the width on your web site that available for the search result. You should get two types of code from the "Adsense for Search" setup page, the "search box code" and the "search result code".

Step 2 – Install your "Search box code"

Copy the code under "search box code" and install the code into your web site. It is the code that display the search box. Put it to a place where user easily see and access (normally at the side bar). If you are using the newer version of WordPress, you can copy and paste the code into WordPress’ sidebar text widget.

Step 3 – Install your "Search result code"

Create a WordPress template page and name it as search-result.php (or whatever you like) and put the file in your theme folder. Include all the necessary coding into the php file (e.g. template name and necessary functions calling). Then copy and paste the "search result code" into the template. Generally, the content of search-result.php should look something similar to this:

<?php
/*
Template Name: Google Search Result
*/
?>
<?php get_header(); ?>
<div id="content">
<!-- Google Search Result Snippet Begins -->
...
<!-- Google Search Result Snippet Ends -->
</div>
<?php get_sidebar(); ?>
<?php get_footer(); ?>

Step 4 – Configure WordPress to show Google search result

Login your blog’s administration page, under "Write" and then "Pages", write a new page and make sure you choose the "Google Search Result" as the template. Give it a title and save it. Edit the saved page, make sure the permalink matches the URL you have keyed in in step 1. If not, modify it.

Step 5 – Test

Open your blog, you should now see the Google Search Box on your web site. Type in some keywords and hit enter. Your site should be redirected to the URL you have configure in step 1. If it redirect to the wrong page or you get and error, make sure you have done step 1 and step 4 correctly.

After that, check that the Google display the search result on you web site correctly. If it doesn’t show anything make sure you have done step 2 and 3 correctly or you can try reenter another keywords (something general).

And that’s all.

More from my site

  • Replace WordPress’ more tag with advertisement codeReplace WordPress’ more tag with advertisement code
  • Wordpress: How To Change Admin UsernameWordPress: How To Change Admin Username
  • Wordpress: Transfer Your Blogs To Another Hosting With Minimum DowntimeWordPress: Transfer Your Blogs To Another Hosting With Minimum Downtime
  • Wordpress: Version 2.9WordPress: Version 2.9
  • Wordpress: Catch A Spam Comment With StatcounterWordPress: Catch A Spam Comment With Statcounter
  • Wordpress: How To Add Table Into A PostWordPress: How To Add Table Into A Post

Filed Under: Programming and Scripting Tagged With: Adsense, Google, Google search result, PHP, Wordpress

About Sze Hau

Geek. Love programming. Coffee addicted. Married with two children. Working towards financial freedom.

Leave a Reply Cancel reply

Advertisement

  • Facebook
  • Google+
  • Instagram
  • Twitter

Email News Letter

Sign up to receive updates daily and to hear what's going on with us

Software and Hardware

MD5 and SHA1 Checksum Using Windows

July 5, 2017 By Sze Hau Leave a Comment

Blog Network

  • Personal Fincance Personal Finance – Personal Money Tips, Stock Investment, Small Business and Make Money Online
  • szehau's weblog Life, Internet, Software, Gadgets, Programming and Investments

Snippet IT

This is the place where I want to share anything about information technology.

Search

Recent

  • MD5 and SHA1 Checksum Using Windows
  • MD5 and SHA1 Checksum Using Linux
  • Java: Unlimited Strength Jurisdiction Policy
  • WordPress: How To Change Admin Username
  • Linux: How To Compress And Decompress Folders And Files

Tags

Adsense advertisement advertising apache blog blogging tips C# EGPC error estimation format format Integer Gmail Google Google Adsense Google Chrome Google Search Engine Google search result how to HTTP internet marketing Java JavaScript Linux money password performance PHP programming search engine optimization secure security short URL SQL static constructor String tiny URL Tips and Tricks twitter video Windows Vista Wordpress wordpress plugin wordpress theme Youtube

Copyright © 2025 · Magazine Pro Theme on Genesis Framework · WordPress · Log in