Walker News

How To Display Adsense Search Result Within WordPress Page

Google Adsense Search not only brings in dollar and cent but is also one of the effective way to look for related articles within the site and the world wide web.

Initially, the Adsense Search result can only be shown on a new pop up window or on the same window with Google.com domain.

Then, there is third option which allows Adsense publisher to display search result within the real same page, i.e. on the same domain and same window! (But, this feature is only applicable to publisher who can create a dedicated search result page for the site.)

How to display Adsense Search Result within WordPress page?
  1. Generate Adsense For Search code in your account – in the More Options section, select “Open results within my own site”.
  2. Create a new page for your WordPress powered site – login to WordPress, click the Write tab follow by Write Page and define the Page Slug as “search”
  3. Edit the page.php (WordPress theme template file) and embed the following PHP snippet right after the_content function call. The is_page function ensure the Adsense Search results will only be shown on a page that called “search”! Enclose the Adsense Seach Result code in the echo statement.
       if (is_page('Search')){
          echo "<!-- Google Search Result Snippet Begins -->....";
  4. Embed the Adsense Search code into the sidebar (sidebar.php) / bottom of post (single.php) where you want it to appear.

The Adsense Search might appear differently or look weird in some WordPress theme. In this case, you might need to change the CSS style of few HTML tags which are used in Adsense Search code, such FORM, TABLE, LABEL, INPUT, etc.

As you couldn’t change the original Adsense code, so the easier way will be assign different CSS class / ID to those HTML tag that construct the overall WordPress theme.

Custom Search

2018  •  Privacy Policy