Integrate and Display Google AdSense for Search and Co-Op Custom Search Engine Results in WordPress Blog Page Template

Google AdSense for Search features the ability to let web publishers to open and display search results within the website itself. In other word, the results of a user search performed in Google AdSense for Search box will appear within a frame on a page from the site, so that rather the users need not to leave the publishers’ websites and being taken to Google, while still able to search for information with Google web search. Beside, Google AdSense for Search, Google Co-op also has Custom Search Engine that can be placed and integrated, together with the search results into website, and comes with more customization options such as search refinements, ads positioning, prioritize or limit sites to include in search results, change and modify the look and feel, collaboration with users, ability to create multiple search engine, make money with AdSense, and of course, ability to integrate into existing website and blog templates.

To integrate, incorporate, embed and display Google search results from Google AdSense for Search and Google Co-Op Custom Search Engine within the template and theme of WordPress blog, we use the similar steps that used to integrate and embed Amazon aStore into WordPress blog by using additional Page template. You can embed the search results code snippets on a new post if you want to display search results based on your WordPress theme’s Post template. However, as Post doesn’t allow you to select a unique custom template for a single post, you will have the same layout among all the post entries and search results. This is not advisable, as sidebar may take up a lot of space, and the theme’s Post template has contains AdSense ads itself or other customisation that will make the embedded search results appear odd. So using a new Page template is better choice, and the Google search results can be made display on WordPress itself without any need of plugin.

To embed, integrate and display Google search displays from Google AdSense for Search and Google Co-Op Custom Search Engine in WordPress blog, try the following steps.

  1. Sign up for Google AdSense or Google Co-Op Custom Search Engine.
  2. When generate the Google AdSense search box code or Google Co-Op Custom Search Engine (CSE) search box code, remember to select “Open results within my own site” (Google AdSense for Search under Opening of search results page section) or “Host a search box and search results on your own site” (CSE under Add this search engine to your website section).

    Google AdSense for Search Results in Site
    Google Co-Op CSE Results in Site
    Key in the URL of the page on your site that the search results will appear. For WordPress page without page parent, the URL should look like this: http://www.yourdomain.com/page-title/ (i.e. http://www.mydigitallife.info/google-search/). Note: trailing slash is insignificant, and can be dropped.

  3. You can do any other customization of your personal Google search engine, such as color, logo, style, layout, language, Google domain’s country, sites to include, and etc. However, it’s out of the scope of this article.
  4. After customizing the search box, generate and get the search box code and search results code. (You must have both code, if not your configuration of search box is wrong.)
  5. Create a custom page template for Wordpress based on your existing Page template. You may retain or drop the sidebar (<?php get_sidebar(); ?> line), as sidebar may take up a lot of your webpage space. If so you will need to adjust the width of search results accordingly during configuration and customisation of search box. Beside, as Wordpress templates are heavily aligned and positioned by using CSS DIV tags, you may need to remove DIV in CSS layout that restrict the width (if you remove the sidebar) or modify the structure of the layout in your Google search results page template. Generally, a Google Search search results page template without sidebar would like similarly like this (comments on template code in italic, can be safely ignored):
    <?php
    /*
    Template Name: Search Results Page
    */
    ?>
    The above section is important so that Wordpress will identify the new theme’s php file as a Page template. You can change the template name though.

    <?php get_header(); ?>
    In Wordpress theme’s header, there may be also DIV tag that controls the width in the Page layout. If it’s the case, the remove this line, the copy and paste the everything from Header template, and modify accordingly.

    <div class=”content”>
    Again, this may restrict the width of layout, if so, replace it with your own DIV structure, or simply with <center></center> (which I used) or just remove the line.

    <!– Google Search Result Snippet Begins –>
    <div id=”googleSearchUnitIframe”></div>

    <script type=”text/javascript”>
    var googleSearchIframeName = ‘googleSearchUnitIframe’;
    var googleSearchFrameWidth = 700;
    var googleSearchFrameborder = 0 ;
    var googleSearchDomain = ‘www.google.com’;
    </script>
    <script type=”text/javascript”
    src=”http://www.google.com/afsonline/show_afs_search.js”>
    </script>
    <!– Google Search Result Snippet Ends –>

    Replace above line with your own Google search results code (not Google search box code).

    </div>
    If you don’t use any DIV above, just remove this line too. If you use <center>, replace with </center>.

    <?php get_footer(); ?>

    Note: You can also exclude the theme’s header and footer (basically mean empty template file just just a line of search results code, which will display only search results, but that defeat the purpose of integration with Wordpress.

  6. Save the new page template for your WordPress theme. You can give it any name.
  7. Upload the new page template with search results code to your Wordpress theme’s directory. So if you’re using Blogsome or Wordpress.com, you may be out of luck.
  8. Create a new Wordpress static Page by clicking on “Write” then “Write Page”.
    Key in Title as what you enter for URL to display search results during setup of Google search box above (e.g if you enter /google-search/ as URL for search results page, you will need to enter Google Search as page title). You page-slug has to be exactly the same with the URL entered as shown in image below.
  9. On the Page Template at the side, choose Search Results Page (or whichever name you gave to the new template).

    Post Template and Post Slug

  10. Save and publish the page.
  11. Edit your template, and put in the search box code to anywhere you like the search box to appear.
  12. The search results from Google is now integrated with WordPress blog. Whenever a user search with the Google search box from AdSense or Custom Search Engine, the search results will appear within your WordPress blog.

For sample of integration and inline search results display in WordPress blog by Google AdSense for search, simply use the search box on top. For Google Co-Op Custom Search Engine, check out Google Medical Search Engine.

Share and contribute or get technical support and help at My Digital Life Forums.



7 Responses to “Integrate and Display Google AdSense for Search and Co-Op Custom Search Engine Results in WordPress Blog Page Template”

  1. NetBloke
    August 20th, 2007 05:26
    1

    I am trying to follow these instructions and am not having any luck with getting the results to appear on the search page.

    I think I am not doing the static page bit right. How do I make it a static page exactly?

  2. jameswillisisthebest
    September 9th, 2007 04:37
    2

    This is my first post
    just saying HI

  3. get it from Boy!
    February 3rd, 2008 11:58
    3

    i really like your ad layouts and of course on how to implement it in wordpress.org sites..

    i hope you make them into wodpress plugins instead so that it will be easier. I’m pretty sure your site will be more popular.

    thanks

  4. ragin'Geek
    May 10th, 2008 14:55
    4

    Is there a way to keep a published page from showing up? My template uses wp_list_pages to display the top level pages in a menu, can i suppress my search results page?

  5. Wordpress Plugin Centre - Clean Wordpress Template - Integrate and Display Google AdSense for Search and Co-Op Custom
    June 12th, 2008 15:41
    5

    [...] Integrate and Display Google AdSense for Search and Co-Op Custom To integrate, incorporate, embed and display Google search results from Google AdSense for Search and Google Co-Op Custom Search Engine within the template and theme of WordPress [...]

  6. Probando el nuevo Búsqueda Personalizada de Google - Primate Blog
    June 15th, 2008 19:02
    6

    [...] cierto, y más allá del nuevo producto Google, recomiendo este pequeño paso a paso que me vino muy bien para poder integrar los resultados en el template de [...]

  7. Radio
    August 14th, 2008 22:49
    7

    Buen artículo aunque las imágenes un poco borrosas. Llevo semanas intentando embedir Adsense en el blog de mi web sin éxito, a ver si siguiendo esta técnica…

Leave a Reply

You can use these tags: <a href="" title=""> <abbr title=""> <acronym title=""> <b> <blockquote cite=""> <cite> <code> <del datetime=""> <em> <i> <q cite=""> <strike> <strong>

Subscribe without commenting


Custom Search

New Articles

Incoming Search Terms for the Article

adsense search wordpress - AdSense for Search wordpress - embedding google search in wordpress theme - ad sense search how to integrate into wordpress - google custom search template - Display your own name in google web page - adsense search box, wordpress blog - how to display results from my google search in my website - wordpress search to adsense search - error google search open results within my own site - embed google search wordpress - how to integrate google search into my website - integrate google search in my website - talian wordpress blog customize - How to Embed Custom Google Search Results into - how to integrate google custom search engine to wordpress blog - integrate google search into wordpress - how do i get me google search results to appear in my template? - adsense search for wordpress - adsense for search no ads showing - bulgaria customised search engine "google blog" - embedding google ads in website - google adsense search box styles multiple choice, custom search - how to integrate google search on your own website - How to implement Google Adsense Search in Wordpress - script to embed google search result page in or php page - sites displaying google search - "AdSense for Search " php script - adsense search - Customizing Google Search results display - google custom search frame width - How do I implement Adsense for search - remove "google custom search" from search result page - ads not appearing google adsense for search - blog google adsense search box - How to incorporate Google Custom Search engine with Adsense into your Wordpress blog - how to add google search box to wordpress sidebar - integrating google search into wordpress - "google search" script header adsense - adsense for search limit search result - embed google custom search - googleSearchFrameWidth adjust - how to add AdSense for search to a page - how to add adsense search into wordpress - modify width of adsense - display custom google search results - google "adsense for search" toolbar - google search integration for wordpress - started boxes style type multiple choice code creates this google adsense boxes - “From Header” översättning -