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...]
What will we do?
- Generate new AdSense search code.
- Create a new Google Search WordPress Page template.
- Create a new Google Search WordPress Page.
- 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:
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).
- Create a new text file with your text editor.
- Copy and paste the following code into the new text file. The code creates a frame in the page to display Google search results.
Template Name: google search
< ?php get_header(); ?>
< ?php get_footer(); ?>[/php]
- Save the file as googlesearch.php
- 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.
- At WordPress admin, goto Write Page under Write.
- Type “Google Search” for the Page Title, but leave blank for the Page Content.
WordPress Page with blank content and “Google Search” as page title.
- On the right, expand Page Template: and select “google search” (googlesearch.php).
- Make sure the Post slug is “google-search”
- 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.
You’re done! You can test your on-site Google AdSense search and see the result at
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!
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.