More from Google Plugin

« Back to WordPress

Now you can easily add search results from Google within your WordPress search results page.

The More from Google plugin adds the required fields to your
search form and outputs the required XHTML and Javascript to display
Google's results within your WordPress search results page. This can be
used:

  • simply to provide your readers with related results from other sites.
  • with google site search to provide the readers with supplemental results so they can search WordPress pages and non-WordPress pages on your site.
  • encourage readers to stay at your site longer.
  • increase your revenue through Google's AdSense for Search program.

The More from Google plugin, also allows you to specify a search term for each post. This search term is used to create a link at the bottom
of your post linking to search results for that term. This encourages
your readers to Google for related articles, without leaving your site.

Download


CC-GNU GPL

This software is licensed under the CC-GNU GPL.


Tip Jar

How it Works

Google provides an option to have their results embedded within your page. To achieve this, Google can provide you with code for a custom search form and code for displaying the results.

The More From Google plugin creates a merged search form, combining Google's search form, with the default WordPress search form. When this merged search form is submitted, it tells both WordPress and Google to perform the search. Because Google's portion of the form
is designed to be destination independent (it doesn't care what what page your results are shown on) there form is still directed to the WordPress search results page.

Your search results page will display the WordPress search results as usual and with slight modification using the display code from Google, it will also show the search results from Google.

The More from Google link at the bottom of each post call a Javascript function that populates the search form and then submits it. Because the embedded results from Google will only be displayed if Javascript is enabled in your readers browser, the More from Google link is only displayed if Javascript is enabled.

Demonstration

Simple go to the end of this page and click on the "Google for AdSense for Search »" link.

Installation

Installing With Themes That Support More From Google

  1. copy the `more-from-google` directory to your `wp-contents/plugins` directory.
  2. Activate the More from Google plugin in your plugins administration page.
  3. When editing your posts, add a search term in the 'Google Search Term' field.

Installing With Themes That Don't Support More From Google

  1. In the theme you are using, make sure the id of the search form is `searchform` and add the following code within the search form:
    if( function_exists( 'mfg_search_inputs' ) ) {
    	mfg_search_inputs();
    }

    for instance, in the default theme, you would edit `searchform.php` and change

    <form method="get" id="searchform" action="<?php bloginfo('home'); ?>/">
    <div><input type="text" value="<?php the_search_query(); ?>" name="s" id="s" />
    <input type="submit" id="searchsubmit" value="Search" />
    </div>
    </form>
    

    to

    <form method="get" id="searchform" action="<?php bloginfo('home'); ?>/">
    <?php if( function_exists( 'mfg_search_inputs' ) ) {
    	mfg_search_inputs();
    }?>
    <div><input type="text" value="<?php the_search_query(); ?>" name="s" id="s" />
    <input type="submit" id="searchsubmit" value="Search" />
    </div>
    </form>
    

  2. In the theme you are using, add the following code to the end of the search page:
    if( function_exists('mfg_show_results') ) {
    	mfg_show_results();
    }
    

    for instance, in the default theme, you would edit search.php and change

    <?php endif; ?>
    
    </div>
    
    <?php get_sidebar(); ?>
    
    <?php get_footer(); ?>
    

    to

    <?php endif; ?>
    <?php if( function_exists( 'mfg_show_results' ) ) {
    	mfg_show_results();
    }?>
    </div>
    
    <?php get_sidebar(); ?>
    
    <?php get_footer(); ?>
    

  3. In the theme you are using, edit the search results page and the following condition to the have_posts if statement:
    (!function_exists('mfg_show_wordpress_search_results')
    	|| mfg_show_wordpress_search_results())
    


    for instance, in the default theme, you would edit search.php and change

    <?php if (have_posts()) : ?>
    

    to

    <?php if (have_posts()
    	&& (!function_exists('mfg_show_wordpress_search_results')
    	|| mfg_show_wordpress_search_results())) : ?>
    

  4. Perform the same steps in "Installing With Themes That Support More From Google"

Frequently Asked Questions

Got any questions?

Release Notes

  • 0.0.2
    • Added support for old WordPress 2.0 installations
  • 0.0.1
    • Better handing of middle clicks.
    • Added BeNice support.
    • Fixed Readme.txt
  • 0.0.0
    • Initial Release
  • « Back to WordPress

    37 comments.

  1. Comment on June 15th, 2007. Reply

    Just installed your plugin and I’m getting no Google results? The plugin is active and I added the code to the searchform.php and search.php. Hmmmmm?

    1. Comment on June 15th, 2007. Reply

      Oh yeah. Using WP 2.2.

    2. Comment on June 16th, 2007. Reply

      I just had a look at your site, and none of the MFG generated code appears in your search form. Are you sure the form on the main page is coming from searchform.php?

      1. Comment on June 17th, 2007. Reply

        Here is my searchform.php:

        /”>

        1. Comment on June 19th, 2007. Reply

          I had a look at the files you sent me and the look correct. Can you email me your the index.php from your theme?

  2. Comment on June 16th, 2007. Reply

    Hey. Is there any way for this plugin to work on WP 2.0? Thanks. :grin:

    1. Comment on June 17th, 2007. Reply

      There is no specific reason why the More from Google plugin shouldn’t work with WP 2.0. I just haven’t tested it. Feel free to give it a go and let know if it does or doesn’t work.

  3. Comment on June 18th, 2007. Reply

    Hey. Ok, I tried it, but I am getting an error when I go to write/edit post in wp-admin. The error is…

    Fatal error: Call to undefined function attribute_escape() in /home/…/wp-content/plugins/more-from-google/morefromgoogle.php on line 176

    Any ideas tom? I’m clued out.

    1. Comment on June 19th, 2007. Reply

      Looks like attribute_escape was introduced in WP 2.1 or 2.2. Add the following function to morefromgoogle.php

      // Escaping for HTML attributes
      function attribute_escape($text) {
      	$safe_text = wp_specialchars($text, true);
      	return apply_filters('attribute_escape', $safe_text, $text);
      }
      

      1. Comment on June 19th, 2007. Reply

        Ah, that did the trick, thanks! Also, this plugin seems to have a conflict with the firestats plugin—After trying a search, the page was filled with mysql errors but turning off that plugin and there was no problem. Though, no search results seemed to appear. Do you need an adsense account for this to work?

        Thanks again Tom.

        A.

        1. Comment on June 19th, 2007. Reply

          I’m downloading firestats to find out what the problem is. I had a look at your site and it appears that either MFG is not enabled or you haven’t modified the theme to support MFG. You don’t need a AdSense account for it to work.

        2. Comment on June 19th, 2007. Reply

          I just installed firestats locally on my machine and didn’t notice any errors. It might just be an issue with wp 2.0.

          1. Comment on June 20th, 2007. Reply

            That sucks about the firestats thing (it’s pretty touchy) but on the bright side I got it working! The problem was the snippet for the search results wasn’t actually on the page.

            You might want to do a quick update to your directions :wink: as I think Step 2 should probably read:

            mfg_show_results

            Right now it says:

            mfg_search_inputs

            Cheers.

            1. Comment on June 20th, 2007. Reply

              Well spotted. I’ve updated the directions. Thanks.

  4. robotsrcool
    Comment on June 21st, 2007. Reply

    The 0.0.2 download link is broken.

    1. Comment on June 21st, 2007. Reply

      Thanks. It’s fixed now.

  5. ne
    Comment on June 22nd, 2007. Reply

    It ugly as you embbed your Adsense for search in it. Anyone who donwload this plugin, plugin author will get paid when anyone did search on your site. Check the code line 332.

    1. Comment on June 22nd, 2007. Reply

      Have a look at the options page for More from Google. It provides an option to set your own AdSense for search code. Hence the “Revenue” tag.

  6. Comment on June 29th, 2007. Reply

    Tom, I just want to thank you for this awesome plugin. It works fantastic. For your info: I’m using WP 2.2.1.

    Only one question is left. (Nothing to worry about. :mrgreen:) I wonder why there is such a big space at the end of the search results. Is there a reason for it? I double checked with a search on your page. The same. So … if you have time one day I would be happy if you could satisfy my curiosity. :wink:

    Thanks again and have a great weekend.

    1. Comment on July 1st, 2007. Reply

      It’s just the way Google’s code works. If I get the chance I might look into some JS which would shrink the i frame after it’s been loaded.

      1. Comment on July 3rd, 2007. Reply

        Thank you, Tom. I just found out by coincidence that the space depends on the options you set up directly for Google search. Usually I’m used to 100 results/page. Since I installed the plugin that must have been overwritten with the standard of 10 somehow. However, I wanted to have my 100 back. After that had been done I realized that there isn’t a space anymore. But neither a pagebar. :mrgreen: I have tested a few options and with 20 results per page it’s perfect. Hurrahhhh … :smile:

        Greetz from Germany. Enni

  7. Comment on July 7th, 2007. Reply

    I’ve installed your plugin on WP 2.2.1 and made the above php changes to my theme (Copyblogger).

    The More from Google link does not function. Do you have any suggestions?

    I know that Copyblogger has its own search. Is this overriding your plugin somehow?

    (The provided link is the only post that I am testing Google search terms on currently.)

    1. Comment on July 9th, 2007. Reply

      Hi, I’ve just had a look and your search form has the id ’search_form’, whereas More from Google expects it to be ’searchform’. You can either edit morefromgoogle.js (replacing ’searchform’ with ’search_form’ or edit the search form itself (which appears to be a widget, so wp-include/widgets.php).

      1. Comment on July 10th, 2007. Reply

        Tom, thank you for checking my site. I made the changes that you suggested, but to no avail. Copyblogger’s search functions is still interfering.

        I get a “parse error: syntax error” message, when I click on the More From Google link. It references a specific line of Boolean logic in the theme’s search.php.

        At this point, I’ll check in with Chris Pearson (www.pearsonified.com) who created the theme to see if he has any work-arounds. I’ll let you know if there are any breakthroughs. Thanks again for your time.

  8. Comment on September 8th, 2007. Reply

    hi there,
    i need some help please…
    i have done all steps but i think i made a stubit thing i change the Google Search Input Fields:
    can anybody send me the code for this field

    1. Comment on September 10th, 2007. Reply

      Hi had a quick look at your site and the only search form I could find points to google, not to your own site, nor does it have an id of “searchform”. I’m I looking at the right form?

      1. Comment on September 10th, 2007. Reply

        i had to disable it… now its on
        please take alook
        thanks

        1. Comment on September 10th, 2007. Reply

          The form is still pointing to http://www.google.gr/custom and doesn’t have an id of “searchform”

  9. Comment on October 10th, 2007. Reply

    Hello. I’ve installed your pluging, and modified all the above mentioned tags but when i use my theme search box it only shows results from my blog, no results from Google.
    Please have a look if you can and tell me whats the problem? Thank you very much

  10. Comment on November 17th, 2007. Reply

    Hi there, just wondering… wouldn’t using this plugin risk your Adsense income because it’s not showing the Google Search Form AND (probably more importantly) you are auto-populating the search term (which from memory, is a BIG no-no!)

  11. Comment on December 25th, 2007. Reply

    doesnt work at all !

  12. Comment on January 6th, 2008. Reply

    I have been trying to make your plug in work with my site, and I have not been able to fix it so the search results have the Google search results in it. The link on the page works, sending me to the search results page. However, the results page only shows the site’s results, nothing from Google.

    The URL is: blogs.malwarelabs.ca

    Thanks in advance.

  13. Felix
    Comment on January 26th, 2008. Reply

    Hi, Tom!
    Thanks a lot, for such a useful plugin.
    As I don’t know nothing about php, could you try to explain, why it’s not working in my case.

    the message i’m getting:

    Parse error: syntax error, unexpected T_BOOLEAN_AND in /mnt/web3/11/65/51711565/htdocs/moi-augsburg/Sub-Domains/blog/wp-content/themes/coffeebreak-10/search.php on line 6

    Line 6 in my search.php is:

    && (!function_exists(’mfg_show_wordpress_search_results’)

    Is this information sufficient for you to say where is the problem?

  14. Comment on February 11th, 2008. Reply

    I also cannot get this to work. However, I notice that there have been no replies from the developer to any of the comments since September 2007. Has development of this plugin ceased?
    Is it incompatible with Wordpress 2.3.2 and up?
    If you’re still around, Tom, I’ll send you my code and page link to take a look, but I followed your instructions meticulously.

    If you’re out there, let us know.

    Thanks

  15. philip
    Comment on March 16th, 2008. Reply

    I am curious as to why you don’t use this plugin on your site?

  16. philip
    Comment on March 16th, 2008. Reply

    Oh wait I see you do, but not utilizing the more from google link. This function only returns a # link and hasn’t worked for me yet through the search function.

  17. Comment on May 23rd, 2008. Reply

    Tom
    I’m using your plugin More from Google on WP 2.5
    Works fine in Firefox, not at all in Opera or IE 7 (no image on submit button in IE either!).
    Any ideas?

Leave a comment

Names and email addresses are required (email addresses aren't displayed), url's are optional.

Comments may contain the following xhtml tags:
<a href="" title=""> <abbr title=""> <acronym title=""> <b> <blockquote cite=""> <cite> <code> <del datetime=""> <em> <i> <q cite=""> <strike> <strong>