WordPress.org

Ready to get started?Download WordPress

Forums

[resolved] Open Google Search results within my own site (4 posts)

  1. archshrk
    Member
    Posted 7 years ago #

    According to Google, you can now have the google search open within your own site, but I don't know how to make it work in WP. I want to add this to a page or php file, right? But it doesn't seem to work.

    <!-- Google Search Result Snippet Begins -->
    <div id="googleSearchUnitIframe"></div>
    <script type="text/javascript">
    var googleSearchIframeName = 'googleSearchUnitIframe';
    var googleSearchFrameWidth = 700;
    var googleSearchFrameHeight = 1500;
    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 -->

    https://www.google.com/support/adsense/bin/answer.py?answer=43862

  2. vijayrajesh
    Member
    Posted 7 years ago #

    You need to do 2 steps for it, First setting up the search box. Second is you need to set the page where you want publish the result, it can be any type of page, i think. And you need to put the another code inside that page.

    However, it seems google uses iframe concept for it.

    Regards,

    Vrajesh

  3. You need to add the code to a page template. Make a copy of page.php (or index.php if your theme doesn't have page.php). Make sure you give it a unique name with code like this at the very top:

    <?php
    /*
    Template Name: Search
    */
    ?>

    Insert the Google code into the new template after the code for the loop but before the closing </div>. Save and upload.

    Now create a new page using your new template. You don't need to put anything in the post section, just the title will be fine. If you're using pretty permalinks, set the slug to something useful like "search".

    Save your new page, and make sure it loads.

    Now go to your Adsense setup, and enter the URL of your new page in the settings.

  4. archshrk
    Member
    Posted 7 years ago #

    LesBessant - you are correct. I was formating my "search page" incorrectly. Found this guide quite helpful.

    http://www.liewcf.com/blog/archives/2006/09/google-adsense-search-results-within-wordpress-pages/

Topic Closed

This topic has been closed to new replies.

About this Topic