Kolbu

Computers, Gadgets and Beyond!
Subscribe


Google News plugin

April 07, 2008 By: webmaster Category: WordPress Plugins

Displays N first news items from a selectable Google News RSS feed, inline or as a widget.

Google aggregates news from over 4500 news sources, updated continously. The results can be retrieved as a number of RSS feeds, where you can create your own specific feed by specifying one of more than 40 regions/languages, and an optional topic ranging from Domestic to Most Popular to Entertainment. Currently there are nine topics, including, of course, All. In addition to this, any feed can be filtered through a search query so that only news items matching your query will be shown. Note that not all combinations of region/language and topic has been enabled by Google but it should degrade gracefully.

This plugin works both as a widget, as inline content replacement and can be used in themes. It can be used as both simultaneously, but there can be only one instance of the widget. Multiple feeds can be configured and used accordingly.

NOTE! Always upgrade to the latest version if you experience problems, most things are fixed already. :-)

The latest version is 2.5.

If you’ve configured feeds that use character sets like cyrillic, arabic and you’re getting errors from WP when trying to view the feeds then your WP MySQL database tables may be created with the wrong character set. Let me know and I’ll give you some pointers.

Download Google News plugin

If you have a question or other comment, use the form below. Thank you!


Known bugs:

  • There is a bug in the WordPress RSS engine, that sometimes show up when people use this widget. If you get something resembling “unknown function debug() in line 504 of wp-includes/rss.php” then that’s one of them. WP is aware of the problem, and apparently a fixed rss.php might be showing up in the next release. As a quick-fix edit wp-includes/rss.php and change line 503 from if ( MAGPIE_DEBUG ) { to if ( MAGPIE_DEBUG > 1 ) {
  • When the widget fails with a php error like the one above, the template goes out of whack. I’ve made sure none of those are my fault in the next minor upgrade due out soon. I’m looking at better workarounds for the bug above first, so release might be a short while yet. Don’t want to spam you all with multiple releases like some widget writers…

Example of inline content replacement.

Default feed <–google-news–>, alternating randomly between two feeds:

A different feed <–google-news#non-default–>:

Shortcode test non-default [ google-news name="non-default" ]:

Shortcode test default [ google-news ]:

Random test:

Shortcodes are only available in WordPress 2.5 and up.

146 Comments to “Google News plugin”


  1. It’s most wanted plugins. Thank you.

    I’ve a question when I used theme that don’t have widget.
    What’s command to implement this plugin? Is it possible to use it?

    1
  2. Hi there! It’s currently not available as anything other than a widget but I’ll see what I can do. Got it working as both a widget and a style inline plugin, but not without duplicating a lot of code. Need to know a bit more about normal plugin coding first, shouldn’t take too long so look for the updated plugin in the near future.

    2
  3. I have a problem with this widget/plugin:

    After activating I get the following mesage:
    %BEG_OF_TITLE%%END_OF_TITLE%
    Fatal error: Call to undefined function: htmlspecialchars_decode() in /var/www/web1811/html/wordpress/wp-content/plugins/google-news/google_news.php on line 79

    3
  4. Ah, bummer. That function is only available in fairly recent versions of PHP I just found out. I’ll see if I can find another way of doing just that. Look for an update to the plugin soon!
    OK

    4
  5. The 2.0 release, written from scratch, is just out. It removes the dependency on htmlspecialchars_decode and also lets you use it both as a widget and as inline content replacement.

    5
  6. Hello,

    for some reason, after the upgrade to v2.0 the settings don’t seem to “stick” if you know what I mean. I upgraded, made the original settings – they first seem to work but get set back to the standard US top news without images, short version after a few page loads…

    Any idea how to fix this?

    Thanx

    6
  7. Hm, strange. I’ll have to investigate. This plugin/widget system is a bit of an undocumented mess imo so I’m not too surprised I’ve missed a spot. :-)

    7
  8. Your plugin looks great! However, I got an error when I tried to activate it. I am running worpress 2.5 -php 5 -almost spring template:

    parse error: syntax error, unexpected T_STRING, expecting T_OLD_FUNCTION or T_FUNCTION or T_VAR or ‘}’ in /homepages/18/d95001024/htdocs/autoinsurance5/wp-content/plugins/google-news/google_news.php on line 38

    8
  9. New release out, that fixes the problem of the settings going missing. Turned out my class gets config updates for all the other plugins as well, without my settings set of course. Should be fixed, sorry about the inconvenience.

    9
  10. Hi, Your plugins are a great value added widget that makes my blogs more dynamic and interesting. I have your CNN up and running, however, even your new version of google news I get the same error mentioned above. If this is anything that I am doing or I can help you trouble shoot this let me know. many thanks

    10
  11. Seems to work fine now, thanks!

    11
  12. Hm…

    I guess they blacklisted my IP…

    did some research and no matter which User-Agent string is being used I get redirected here if the request comes from my server:

    http://sorry.google.com/sorry/?continue=http://news.google.com/news?output=rss&imv=1&ned=de&topic=h

    Did you actually get that plugin approved by google?

    12
  13. Hi JOKER!
    I read their Terms of Service, and didn’t see anywhere I had to apply to get an RSS reader approved. I followed their requirements when writing the plugin though, keeping the links as they came from Google, making sure the title of the news clearly stated that they came from Google etc. That was about all I could find in terms of requirements. I’ll investigate further. I’m not blocked on any of my sites however, so it may be something else on your network. Do you have a busy site with lots of requests?

    13
  14. Not many requests yet – no…

    I’ll get in touch with Google and see what they have to say.

    I’ll keep you updated.

    Besides, it might be a good idea to actually cache the feed for X minutes, so they don’t get bombarded with requests from heavy sites and in the end ban the whole plugin.
    Just an idea for improvement.

    14
  15. Hi Mark!
    Which version of Google News do you run? Line 38 in the plugin in the latest release (2.0.1) is in the middle of an array description. Incidentally the first reference to UTF8 characters, as it’s says Hindi in well Hindi. Your PHP may not like that. I’ll see if I can get hold of the actual &#nnnn; characters to use instead. But if you’re using an older version of the plugin, please download the newest and see if that works better. Let me know!

    15
  16. Hi JOKER
    Yeah, caching is next on the list. Shouldn’t be too difficult, so probably new version by the end of the day. :-) I’ll contact Google as well and see if I can get an accredited browser uid or something.

    16
  17. Hi Mark,

    ist there a solution to put the output in a template page like single.php after a similar posts. That was great. Its a little complicated to put always the <!–google news–> code in the post.

    Thanks

    17
  18. Hi thank you for the kind reply. 1) I am on version 2.01. 2) I deleted the line with refernce to hindi but it gave me an error 3) I can take this off line and write you directly if you do not want me to take up space on your blog :) 4) I did not fully undertand what you mean about “to put the output in a template page ” but I can edit anything, I know some but not alot of php. Just tell me what to so or ask any questions. I thank you very much for your kind help with your word press google news plug in.

    18
  19. Hi, do you have any reply from google yet?

    I have none, and I still get the 403 – not all the time, but most of it… it also makes my sites very slow to load…

    Unfortunate, I really liked this plugin.

    19
  20. Hey…

    I’ve rewritten your plugin to actual WordPress standard – making use of the internal MagpieRSS functions and RSS feed caching module.

    Let me know of you want to have the updated code.

    Steve

    20
  21. Hi Joker.
    No word from Google, but not sure if I used the right channels. I’ll poke around some more in their help system.

    Wow, there is an rss system built in? Man, the wordpress docs leave a lot to be desired. :-) And here I’ve just implemented a caching system for the next release, and reworked the internal data structure to allow for multiple rss feed configurations in the release after that. I’ll have a quick look at the wp rss docs and see if it’s faster just to redo it myself instead of retrofitting your updates into the new release. Thanks for the information though!

    OK

    21
  22. How do i use this as tag in the template to show the feeds?

    22
  23. This google news plugin is simply amazing! Thank you very much for creating it. The reason I like it is, it gives you flexibility to filter the news that you like. If you are a wordpress user, I recommend it.

    23
  24. Sorry, I posted this under your CNN plugin my mistake:

    I loved your Google News plugin. I installed it yesterday and everything looked great for for 4 hours or so. Later I pulled up my site and my posts were gone. I was getting the following error under the Google News widget:

    Fatal error: Call to undefined function debug() in /html/wp-includes/rss.php on line 504

    I deleted the feed and added a new one. My posts were back but now I’m getting this error under the widget:

    Google News unavailable

    This makes me think Google changed something on their end. I hope this isn’t specific to me.

    24
  25. chandru says:

    Hi, Really a great work.. But how can I display archives from google news? is there any way to display archives of a particular search terms?

    25
  26. Hi braddock!
    Your problems are vaguely familiar to the ones I had before converting my WP database to UTF-8. That is, your WordPress installation is UTF-8 (as defined in your wp-config.php) but your MySQL database tables are in some other character set. If you connect to your database using the mysql command and then do ‘show table status;’, what does it say under the Collation-column? If it does not say something with utf8 in it, then your database most likely was created using an older WordPress than your currently use. There was a bug at some point, where the database tables were created using the system default (generally latin1) instead of the WP default. So now your blog saves the cached Google News feeds using UTF-8 in a table not meant for UTF-8 and gets an error when fetching the cached page again. The bad part is that you have to change your whole WP database, the good part is that someone wrote a plugin to do it. http://wordpress.org/extend/plugins/utf-8-database-converter/
    Note specifically that this plugin is fairly old and not updated wrt WP 2.5. However, I went ahead despite the warnings on my 2.5 and it seems to have worked fine. Your mileage may vary, make sure you do a database backup before trying!

    OK

    26
  27. Hi chandru!
    No support for Google archives, wasn’t even aware that they had an archive. I’ll go look for some documentation on how to generate RSS feeds out of old news and release an update when/if it’s possible. Thanks for the info!

    OK

    27
  28. Hi Olav,
    I was thrilled to find this plugin! I would like to change the way the images are displayed. Currently I have chosen Output: With Images and Item Length: Long (I’ve also tried this with standard output), and I would like to change the look in two ways.
    1) There is no spacing between image and text which looks like an error.
    2) The image aligns to the bullet on the bottom.

    Ideally, I’d like to align the image with the bullet at the top left of the image. Then I’d like a line break so the text would begin under the image. (Or it could wrap the image to the right provided there was enough of a margin between the image and text.)

    Is there a way I can change this?
    Thanks. — Jane

    28
  29. Hi Jane!
    As noted in the plugin documentation, the markup here is actually what Google provides. Each item in their RSS feed is a mess of tables, font settings and other useless HTML code. I’ve tried cleaning it up a bit, but it appears that the specific markup also depends on the source Google uses for a particular news item. So don’t expect the output to be too stable. :-)

    By adding a few lines to the CSS file of your theme, you should be able to fix most of this on your own though. E.g. if you add this:

    #google-news-inline img {
    margin-right: 10px;
    }

    you should get a 10 pixel margin to the right of every Google News picture. Similarly you can add other markup to change text, wrap, font etc.
    Note that for Google News as a widget instead of inline, the code would be

    #google-news img {
    margin-right: 10px;
    }

    Similarly, CSS should also be able to wrap the text as you want etc.

    Hope this helps!

    OK

    29
  30. ahmed says:

    how can i install it??????? or what the change i will make in files??????

    30
  31. I luvd the stuff, thanks a bunch.

    But I can’t get news in Brazilian Portuguese… I tried several possibilities, always setting the region to Brazil, but if I put any filter the thing doesn’t work. I cleaned cache evrtime I chgd options, but it only shows news in Eng, otherwise blank.

    The filters I applied were “only Portuguese” “PtBr” “futebol” “only Brazilian Portuguese” combined with several options…

    Is there athg else I can do?

    Tnx again,

    Maciel

    31
  32. I would like to add a widget to my sidebar that display Google News specifically for the keywords “Tybee Island”. I have installed your widget but can not seem to get it to work. I am running WordPress 2.5.1.

    Any ideas?

    When I have the widget added it displays…

    “Google News unavailable” instead of the feed.

    Any ideas would be great.

    Thanks! Katrina

    32
  33. Hi Maciel!
    Google states on their RSS Feed help pages that they haven’t covered all possible combinations of areas and languages yet. Presumably brazilian portugese is about to be implemented since they have a tag for it, but not quite yet. So I’m afraid you’ll just have to wait a bit. Sorry about that!

    OK

    33
  34. Hi Katrina!
    Do you always get the “unavailable” message no matter what type, region and query-filter you use? If so there may be something blocking the plugin from getting to the Google RSS Feed server from your blog server. Try selecting “U.S.” (Region) and “All” (Type) without a query filter, and see if you get any news at all that way.

    OK

    34
  35. Hi ahmed!
    Do you have WordPress installed on your server at all? If so, the zip file should be unzipped in the directory where all your other WordPress plugins are installed. Typically wp-content/plugins/ under your DocumentRoot. Then the rest should be managed through the admin interface in your WordPress blog.

    There is absolutely no need to change anything in any file to install it, but you have to be running WordPress as your blog engine. If you are not, then you can not use this plugin.

    Hope this helps!
    OK

    35
  36. We have two problems with the Google News plugin:

    When we use the widget within a sidebar all is fine as long as the Google feed is up. If they go down, the error out message does not recover the CSS DIV status which crashes our page layout.

    To get around this problem we installed inline do code which fails to find either a default or defined feed that displays properly in the widget.

    Here is the error message when we use the default:

    Warning: Invalid argument supplied for foreach() in F:\WWW\newsroom-magazine.com\wp-content\plugins\google-news\google_news.php on line 739

    No default feed available

    If we define the feed we get this error message:

    Warning: Invalid argument supplied for foreach() in F:\WWW\newsroom-magazine.com\wp-content\plugins\google-news\google_news.php on line 739

    Unknown feed name frontpage used

    the above feed by that name works in the widget.

    36
  37. Hi Robert!
    I’ll fix the runaway div, probably forgotten to close one when it errors out.

    I’ve never tried the inline code in a widget, so that’s a new one. I’ll try it out to see why it fails there. Obviously the plugin code is run, since you get the error messages you get which are from the plugin, but other than that no real ideas until I try it out.

    Expect a minor update soon. :-)

    OK

    37
  38. Using the CNN and Google news widgets..

    Internal links in admin have an extra bit of code that I wonder how to get rid of..

    http://trade-the-news.com/wp-admin/edit.php?page=google-news/google_news.php

    the ‘goole-news/’ bit in the link sends me to a page that doesn’t exist.

    When I remove the bit, link works fine (ie: http://trade-the-news.com/wp-admin/edit.php?page=google_news.php

    ..where do I make that adjustment so the links work without any problem.

    Running WordPress 2.5.1

    Thanks!

    Sean

    38
  39. Hi Sean!
    Where in your directory structure do you have the google_news.php file? Is it wp-content/plugins/google-news/google_news.php or just wp-content/plugins/google_news.php ? Both will technically work in WordPress, since it looks for plugins both in the plugins dir and one level down from there. The former is the correct place for the google news plugin however, and if yours is located directly in the plugin-dir then you should create a google-news directory and move the google_news.php file into there. All this should be fine if you unzip the plugin zip file in the right place though.

    Let me know if this helps.

    OK

    39
  40. I moved the plugin into its own google-news directory as suggested and that fixed the problem ..didn’t think of that. Good to go! Many thanks.

    sj

    40
  41. Karan Anand says:

    hello there
    i am have a problem which katrina here is having . i am getting a message “Google News unavailable”.

    this comes irrespective of which option of country etc. i choose. also plz tell me if this could be in any relation to things which a host server might block(i have a free hosting). just like fopen() function is blocked in many free hosting (because of this i cant use any API related plugin.

    41
  42. Hi!

    first of all, thanks for this wonderfull plugin.

    I have website in portuguese and I configure the google news to show news from Brazil. In the beggining it works great, but in the last 2 or 3 days it start showing only news in English.

    Any glue of what is happening?

    thanks,

    Morgan

    42
  43. Marty Martin says:

    The plug-in has been working perfectly for me until just now. I now get an error that says “Unknown feed name local used”. In admin, the feed is still there, nothing has changed except I deleted a user from the user list.

    Any ideas? I have double-checked code (which wasn’t really necessary since it was working for several days before this happened without any changes at all) but found it to be exactly as before…

    My code is –

    And setup in admin is-

    1 local From Google News U.S. All Standard Short 10 asheville, nc

    HELP!?

    43
  44. Marty Martin says:

    Edit to my post from yesterday– After posting I disabled and then enabled the plugin and it was back to working, but then this morning it’s down again. Tried to disable/enable but no luck this time…Any idea?

    44
  45. Hi!

    I have installed your plugin to show news from Brasil in portuguese in my website… I changed the code from:

    “$feedurl = ‘http://news.google.com/news?output=rss‘ ” to

    “$feedurl = ‘http://news.google.com.br/?output=rss‘ ”

    and for a week or two it worked as a charm… but from 2 or 3 days from now it start showing just news in english…

    Any suggestion of how to solve it?

    Thanks,

    Morgan

    45
  46. Hi Karan!
    If Google is unavailable all the time, then it’s most likely a problem at your hosting provider. They may, as with Katrina, be a PHP configuration option that blocks outgoing connection attempts. It may also be a firewall that block outgoing connections. Do you have access to the webserver logs for your site? If so, see if there are PHP warnings/errors there that may indicate that outbound access is blocked. Either by PHP settings or an external firewall. Also, if you have access to the web server itself, you can try to access something remote with “telnet http://www.google.com 80″. If that fails, then you’re most likely firewalled. If that’s the case, the plugin won’t work unless you get them to open up. Note they will have to open for several external addresses at Google, so let me know if that’s the problem and I will provide you with the sites to open for.

    OK

    46
  47. Hi Morgan!
    No idea on the portugese/english problem. Can you delete your feed, create a new one and see if that works? It may be that Google has changed something at their end, in which case I will have to investigate further. Do you have an RSS feed reader that you can look at the Google feeds with? If so, are they now in english or portugese?

    OK

    47
  48. Hi Marty!
    Not had your problem before. First off, do you display your news using a widget or inline? Secondly, are you well versed enough in mysql that you can do a couple of select statements for me? If so, email me at olav@ (obvious domain name) and I’ll see what I can do.

    OK

    48
  49. Hey,

    I installed the Google News plugin on a website, and it’s not working properly when I use the inline with the theme, but it works fine as a widget. I installed this code: in a theme, and I get an error message saying:

    Warning: Invalid argument supplied for foreach() in /home/deafvil/public_html/news/wp-content/plugins/google-news/google_news.php on line 739

    No default feed available

    Do you know why this could be happening and how can I fix this problem?

    Thank you!

    Rachel

    49
  50. Hi,
    Nice plugin.
    Can I set it to open a second browser page

    50

1 Trackbacks/Pingbacks

  1. just built our new 2012 Page with a high-detail image of a Maya Calendar | mini-tick.com 19 11 10

Leave a Reply

*