Home | Flickr Photos | Links | About | Resume | Contact Me

Wordpress Google Reader Plugin

I have wanted to display items marked as “shared” from my Google Reader on my blog for a while and today I finally sat down and wrote a plugin to do it. You can download the source at http://mike.crute.org/downloads/reader_shared.phps

I wrote the plugin with the following two assumptions: you must have a copy of PHP with SimpleXML and you must have url_fopen set to true. I also do not do any error checking on the settings page so if you feed it bad settings its likely to bomb in a very un-graceful way.

To use it just drop the code in your wp-content/plugins directory and set the settings on the Options page. Then modify your template and add a call to readerShared(); wherever you would like to see the listing of your shared items.

The “I’m Reading” box on the right hand side of this blog is powered by this code.
Update (1/17/07): The Google Reader folks where nice enough to point out my little Wordpress plugin on their blog. If I get enough interest I would entertain maintaining and extending the plugin. If not, it still suits my needs.

28 Responses to “Wordpress Google Reader Plugin”

  1. Any plans on releasing a Widgetized version?

  2. I’m not sure what kind of widgets you’re talking about (everybody has widgets these days). If it would be useful I could probably widgetize it.

    -Mike

  3. A widget would be fine, to integrate it directly to a k2 based wordpress theme, and those who use widgetable theme. Good job.

  4. Awesome! Will set it up in a couple of days. I have been wanting to do the exact same thing. Thank you.

  5. Mike, thanks for contributing by writing this plugin!

    I will install it on my blog in a few days as well!

    May I suggest that you mention a “running example” on your post? I assume that the section “I’m Reading” on your blog was generated by your plugin, but I will only be sure once I install it and test it myself.

  6. Just what I was looking for. I experimented with creating a page and putting an iframe there but that didn’t look good.

    Anyways I have a question regarding your assumptions:
    How can I make sure that “url_fopen” is set to true?

    It would really help if you could provide more detailed walk through of installing and using this plugin.

  7. Hi,

    Thanks for the idea to include the list of shared articles on a WordPress Blog.

    However, if your host doesn’t allow the SimpleXML PHP functions, here is a little trick:
    * In Google Reader, create a clip of your shared items with the following settings: Title=” & Color scheme=’None’.
    * In your WordPress template, include the code provided by Google Reader which outputs style list that you can handle with CSS

    See the example at the end of my blog (ok … in French but still, at the bottom)

    Enjoy…

  8. great plugin. i am looking for something similar for typepad. any suggestions?

  9. When I go to Options -> Google Reader, a blank screen is show. Any ideas?

  10. Al - the plugin is designed to go directly into a template, not in an iframe. You can set url_fopen in your php.ini file or use ini_set()

    Marco - do you have SimpleXML and PHP5?

  11. Great idea for a plugin Mike!

    This is driving me up a wall though, when I go to access the Options page I get this:

    Fatal error: Cannot redeclare readershared_menu() (previously declared in /home2/*username*/public_html/wp-content/plugins/reader_shared.php:64) in /home2/*username*/public_html/wp-content/plugins/reader_shared.php on line 65

    Thoughts?

  12. readerShared_Menu is the function that add the admin menu, it is the last function at the bottom of the code. In the original code it is only declared once. You’re welcome to email me what you have have and I’ll try to help I’m mcrute over at gmail.

  13. I don’t use WordPress or Google Reader, but my girlfriend does and was
    interested in this. And thanks you! But we don’t have url_fopen
    enabled, and so I have added support for cURL. Also, we had the same
    problem (”function already defined”) as David Morgan. Perhaps
    wordpress, or a particular version of it, reads in the file more than once, so I surrounded that (and
    other functions that I made) function definition with an if (
    !function_exists(...)) { ... }
    . I’ve also added the option to
    excerpt content from each feed. You can find my modifications at http://jeremy.smallinfinity.net/wordpress/
    and see it in action at http://scriniary.smallinfinity.net/blog/.

    Hopefully all the bugs are out…

  14. For those wanting a widget version of this,
    -Simply get the RSS link for your google reader shared page
    -Go to the edit sidebar widgets in wordpress dashboard
    -Add a rss widget to the sidebar
    -Paste the the above RSS link in to the RSS widget options.

    Voila. Your Google reader shared page for all to see on a RSS feed.

  15. First of all many greeting Mike, this plugin is very intersting.
    I have download latest version of this plugin and I’ve uploaded it into my blog which running on Wordpress 2.0.7.

    I’ve switched on the plugin configured it with its panel and edited the sidebar template.
    But nothing else. When I update the main page I can’t read any sharing feeds.
    If I open the link that I have used of my google reader sharing feeds all working fine.

    Any suggestion about this problem?

  16. Hi HJOGI… The plugin works on WP 2.0.7 (thats what I was running up until yesterday). Are there any PHP errors on the page or does the page fail to render fully? Also, make sure you are pointing at the ATOM feed for your SHARED items, if you try to point the plugin at a private feed (like your starred items feed) or a non-atom feed you won’t see anything. Let me know if that still doesn’t work.

  17. This is amazing. I’ve been looking for something like this for a while!

  18. I’m getting the same error as commentor David Morgan did above. I sent you an email but wasn’t sure if you got it. Do you know of any way to resolve that issue?

  19. Hi Amish… take a look at the comment by Jeremy Michelson. He just wrapped the function def in if(!function_exists(…)) { … } that should solve the problem for you.

  20. Would love you to package this in a way that made it accessible to technical novices, like me, who don’t know what it means to “have a copy of PHP with SimpleXML and url_fopen set to true”. I tried opening the file above, saving it as a text file the ftp-ing it to my wordpress 2.1 plugin directory where I activated it. And recieved a scarey error message so I took it out because I obviously have no idea what I’m doing.

    I’e wanted something that does this since my baby-blogging days on msn spaces….
    Thanks :-)

  21. Thanks for a cool plugin! I’ve just discovered Google Reader today (I know! Where have I been?) and will be adding this to my site this evening. Very nifty!

    Thanks for making it available!

  22. It appears that Google has changed their XML format, which is breaking the links in the sidebar. A solution is to remove the “[1]” from the argument “$item->link[1]['href']” in the printf near the end of the file:

    printf('<li><a href="%s" rel="nofollow">%s - %s</a></li>',$item->link[1]['href'],$item->title,$item->source->title);

    This will work at least until Google changes the format again…

  23. After reading this post, and then writing a similar one about my struggle to implement a plugin similar to yours I noticed you may not really need a plugin.

    If you select the ‘none’ theme when selecting the style from Google Reader it just produces standard ul/li tags. All you have to do is apply your style to them and it will have a similar affect.

    Check out the post below (more specifically, the UPDATE section) to get more details.

    Using Google Shared Items in your Blog

  24. Thanks for the tips! This works great!

  25. Nice widget. I’ve been looking for something like this.

  26. Found your plugin before I came across Google reader! Now am a fan of both!

  27. Thanks for your advice. This is great stuff.

  28. Nice Site!

Leave a Reply




DISCLAIMER: The opinions expressed on this website are mine and mine alone, they should not be interpreted as the views of my employers, past or present, my family, my church or my pets. Comments are the property of their posters and I can not be held accountable for those.