Home > Tech > How To Display Adsense Search Result Within Wordpress Page (with Default Template)

How To Display Adsense Search Result Within Wordpress Page (with Default Template)

November 6th, 2008 x=vv= Leave a comment Go to comments

Google Adsense Search not only offers users site search or the world wide web search, but while brings in web publishers revenue from ads relevant to their search terms.

Initially, the Adsense Search result can only be shown on a google landing page, that is, a new pop up window or on the same window under Google.com domain.

There is third option now which allows you to display search result within your own specified landing page. For example, the search result can now be displayed on a user-defined page (e.g. site-search page on this site), or even the same window where the search form resides. Of course, you would have to be able to create such dedicated search result page yourself.

Next, I will show:

A step by step tutorial on How To Embed Adsense Search Result within WordPress page:

  1. First, login to your adsense account and generate Adsense For Search code as usual. When you get to the section “Opening of search results page“, tick the option “Open results within my own site“.
  2. Under “Enter URL where search results will be displayed“, enter the URL where you’d like your search result to be displayed, e.g: http://<YOURDOMAIN>/site-search. (You may change the page “site-search” to other names, but make sure the “Post Slug” (in older version of WordPress) or the “Permalink” for this page is changed accordingly.)
  3. Finish the setup wizard until you reach the final page where two blocks of code (search box code & search results code) are shown.
  4. Open up your WordPress admin portal, and copy the search box code to the place where you would like your search form to be (A good option would be a sidebar widget of “text” type).
  5. Create a new WordPress page (a default template will do). Initial the title as “Site Search” so that the Permalink for this page would probably be http://<YOURDOMAIN>/site-search. If you happen to have the same name in your previous post, you can simply edit it to something else. If you are using older version of WordPres, probably there is a “Post Slug” option on the right column. Set the slug as “site-search” then.
  6. In the content field, paste the search results code onto it.
  7. Save and publish the page. That’s all. Enjoy it!

When you test your on-site Google AdSense Search page, you may find the frame in search result page might appear differently or look ugly for some Wordpress theme. This is because Google uses its own style to render those elements. As far as I know, till this end, Google Adsense doesn’t support the customization of the style for Search Result Frame (such as making the background of search result be transparent). But you might be able to change the CSS style to some corresponding HTML tags that are used in Adsense Search Box Code, such as FORM, TABLE, LABEL, INPUT, etc.

There are also many other methods in displaying search result in WordPress Page. A common method among them is to create a new template page, and put the search result code in it. This gives you freedom for controlling (e.g. you may now embed some PHP code in this template), but is not necessary if you want the page to merely display the search result. The page site-search on this site is created based on Default template only.

  1. No comments yet.
  1. No trackbacks yet.