| |

Google AdSense Search Results within WordPress Pages

As promised in my previous post, here is the instruction to having AdSense search results within WordPress Pages.

Wordpress Pages are like Posts, except they can do much more than Posts, and they live outside of the normal blog chronology. [Read more…]

Table of Contents

What will we do?

  1. Generate new AdSense search code.
  2. Create a new Google Search WordPress Page template.
  3. Create a new Google Search WordPress Page.
  4. Insert AdSense search box code into WordPress template.

Step 1: Generate new AdSense search code

Generate AdSense for search code as usual, but tick “Open my results within my own site” at Opening of search results page under More options section.


Select “Open results within my own site”

The URL should be: http://www.YourDomain.com/google-search/

Note: You may change the “google-search” to anything else, but make sure you change the “Post slug” when creating a new WordPress Page for Google Search (Step 3).

Then, you will get two blocks of codes. The first part is search box code. The second part is search results code. Copy both of them.

Step 2: Create a new Google Search WordPress Page template

Now, we need to create a new WordPress Page template and insert search results code into it. In this example, I am using WordPress default theme (Kubrick).

  1. Create a new text file with your text editor.
  2. Copy and paste the following code into the new text file. The code creates a frame in the page to display Google search results.
    [php]< ?php /* Template Name: google search */ ?>

    < ?php get_header(); ?>



    < ?php get_footer(); ?>[/php]

  3. Save the file as googlesearch.php
  4. Upload googlesearch.php into your WordPress theme folder, “default” folder in this example.

Note: If you are using other WordPress templates, you might need to edit page.php of the template, strip out WordPress code, and save as googlesearch.php.

Step 3: Create a new Google Search WordPress Page

Now, we need to create a new WordPress Page using the new WordPress Page template(googlesearch.php) to display Google search results.

  1. At WordPress admin, goto Write Page under Write.
  2. Type “Google Search” for the Page Title, but leave blank for the Page Content.

    edit google search page
    WordPress Page with blank content and “Google Search” as page title.

  3. On the right, expand Page Template: and select “google search” (googlesearch.php).

    Select page template

  4. Make sure the Post slug is “google-search”

    google search post slug

  5. Save the WordPress page.

Step 4: Insert AdSense search box code into WordPress template

Finally, replace your existing AdSense search box code on WordPress template files with the newly generated search box code in Step 1. Save your template files and upload to your server.

Congratulations!

You’re done! You can test your on-site Google AdSense search and see the result at http://www.YourDomain.com/google-search/

Please let me know if you have any problem when implement Google AdSense search results within WordPress Page.

Of course, for those did it, please show us your Google Search WordPress page!

FAQ

Q: How do I hide the “Google Search” page from my page list?
A: You can hide certain WordPress page by using exclude argument in the wp_list_pages template tag. Please refer to “Exclude Pages from List“.

Let me do it for you

Are you still blur and don’t know how to do it? Hire me to do it for you. :)

adsense, google, search, searchengine, tips, wordpress

Share this:

Similar Posts