Humility and building a WordPress Plugin

calendar Posted on February 9, 2007   comments 3 Comments

I've blown most of the last two hours trying to write, what seems to me, a very simple WordPress plugin.

I hate being humbled.

I can get it to show up in the Plugin Page listing and activate, but it doesn't seem to be doing anything. I gotta find some geekier contacts, this is just awful! What am I missing? Or better, how do I figure out what's going wrong?

PHP:
  1. function st_addRelatedtoFeed ($content) {
  2.     $content .= '<p>Chris was here</p>';
  3.    return $content;
  4. }
  5.  
  6. add_filter('the_content_rss', 'st_addRelatedtoFeed');

No, that's not what I actually want it to do. That's the over-simplified version just to try and figure out what the heck I'm doing wrong. (because hey, I'll be the first to admit that my PHP-fu is rather weak).

Looks simple, right? In the example above, I want 'Chris was here" to be appended to each post that shows up in my feed. But when I view the feed on my test blog, I don't see any hint of this sucker being active. I bet I'm missing something trivial.

Long term, I hope to have a plugin that shows Related Posts for each article in my feed, just like I show here on the blog. I was inspired by this article, but I don't use that plugin anymore. I use the UTW function ShowRelatedPostsForCurrentPost() here and I'd like to figure out, eventually, how to use it in my feeds as well.

And I wish to avoid hacking core WP files while I'm at it.

Have any ideas? I'm all ears.

[Update a day later] Turns out, as some would suspect, I'm a dumbass. ;-) When testing something that modifies the feed, one should be sure to test with full feeds, not excerpted feeds. Especially if one is adding content to the end of the content. Doh!

tags Tags: , , , ,

Related Posts Possibly Related Posts

Comments

3 Responses to “Humility and building a WordPress Plugin”

  1. Vidyut Kale on March 2nd, 2007 2:51 pm

    Hi,

    I’m pretty new to this experience too, but have you figured out where you will call it from the template? Without that, where can the code show?

    I think you will need to put something like

    to an appropriate place in your template to get this to work.

  2. Again on March 2nd, 2007 2:56 pm

    Sorry. Its not happening, but you can easily write it yourself. Just put the opening tag, the function and the closing tag in a suitable place on your template. I think it should work with that.

  3. Chris on March 2nd, 2007 3:00 pm

    Hi Vidyut — I’ve been fortunate so far. The 3 plugins I’ve released haven’t need theme tags, they all “just work”. 2 were related to feed processing and the 3rd just enables a button on the editor.

Leave a Reply




Have you read the Comments section on the Disclaimer page?

About

Wandering the Internet, looking at all things bright and shiny. Playing with many, writing about some. More …

Recent Posts

Recent Comments: