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:
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.
This software is licensed under the CC-GNU GPL.
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.
Simple go to the end of this page and click on the "Google for AdSense for Search »" link.
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>
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(); ?>
have_posts if statement:
(!function_exists('mfg_show_wordpress_search_results')
|| mfg_show_wordpress_search_results())
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())) : ?>
Got any questions?
hi
i have installed the theme and edited search.php.Still the search more is not working on my site!Pls assist me to activate this.
Dear creator of the plugin,
1. is there some way to add Adsense for Search results instead of normal google search results delivered by this plugin?
2. This plugin is not automatic. we need to change the theme search form, etc. can this be automated?
i donot know whether i will get your reply in my email.Kindly reply to my email also.
Thanks
any real sample for that…??
how to activated google search at my blog.
http://www.dehexagon.com..
please your advice
[...] 16. More From Google Adds related Google search results to your posts download [...]
Hi
The wordpress theme i have is vistalicious and i have copied the 1st part of code into the search form but cant find a suitable place to put the second and third parts of code. The search includes my code but the results wont show, I have tried placing the code in various places. Is it possible for you to help me place it correctly and get it working so I can donate.
Regards
Simon
Killer. Thank you.
It will take me some time to back-tag all of my posts, so in the interim I added a couple lines to mfg_get_search_term():
function mfg_get_search_term() {
$searchterm = get_post_custom_values('mfg_searchterm');
$jhmposttitle = get_the_title($post_obj->ID ); // JHM 2009-06-26
if( !empty($searchterm)
&& !empty( $searchterm[ 0 ] ) ) {
return $searchterm[ 0 ];
}
else if( $jhmposttitle ) { return $jhmposttitle; } // JHM 2009-06-26
else return null;
}
If there is no searchterm provided, this default to searching Google for the post title.
support wpmu??
enforce wpmu sitewide search?
[...] page du plugin [...]
[...] More from Google [...]
[...] More from Google [...]
[...] More from Google [...]
Hi,
I have two things that i would like to do.
1 – Make your plugin with Ajax? When you click on next link to show the second page results of google, this one come at the top of the page and you see again all results of your blog and you must scroll down the page to see the google results
2- If you do not make an Ajax version, could you explain how to have a search form with two radio button : one for your web site searching and other for google??
Thanks, your plugin work well on Wordpress 2.6.
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?
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.
I am curious as to why you don’t use this plugin on your site?
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
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?
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.
doesnt work at all !
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!)
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
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
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?
i had to disable it… now its on
please take alook
thanks
The form is still pointing to http://www.google.gr/custom and doesn’t have an id of “searchform”
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.)
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).
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.
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.
) 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.
Thanks again and have a great weekend.
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.
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.
I have tested a few options and with 20 results per page it’s perfect. Hurrahhhh …
Greetz from Germany. Enni
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.
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.
The 0.0.2 download link is broken.
Thanks. It’s fixed now.
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.
Looks like
attribute_escapewas introduced in WP 2.1 or 2.2. Add the following function tomorefromgoogle.php// Escaping for HTML attributes function attribute_escape($text) { $safe_text = wp_specialchars($text, true); return apply_filters('attribute_escape', $safe_text, $text); }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.
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.
I just installed firestats locally on my machine and didn’t notice any errors. It might just be an issue with wp 2.0.
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
as I think Step 2 should probably read:
Right now it says:
Cheers.
Hey. Is there any way for this plugin to work on WP 2.0? Thanks.
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.
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?
Oh yeah. Using WP 2.2.
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?
Here is my searchform.php:
/”>
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?
Well spotted. I’ve updated the directions. Thanks.