"Number of Comments" in XML feeds in WordPress

On December 26, 2006, in Web, by peterb

I got this working today in the Atom, RDF, and RSS 2.0 feeds. It’s not working in the RSS 1 feed, but WordPress’s RSS 1 feed sucks anyway, and if you’re using that feed you should change to a different one.

Using the RDF feed as an example, all I did was change this line:


<content:encoded><![CDATA[<?php the_content('', 0, '') ?>]]></content:encoded>

to this:


<content:encoded><![CDATA[<?php the_content('', 0, '') ?><p><?php comments_popup_link('Comment now »',
'1 Comment »', '% Comments »', 'commentslink');
?></p>]]></content:encoded>

Hope that helps those of you who were looking to do something similar.

 

5 Responses to “"Number of Comments" in XML feeds in WordPress”

  1. Wait — but where does one find this piece of code? I’ve looked through all the files in my wordpress theme editor, and can’t find anything that says ….

  2. peterb says:

    It’s not in the theme editor, regrettably. You need to log in to the shell account wherever your wordpress installation is hosted and edit the files with names like “wp-atom.php” “wp-rss.php” “wp-rss2.php” and “wp-rdf.php”

  3. Thanks dude — I think I’ve got it working — Yay! You’re the sweetest :)

  4. Ok — I sort of have it working, but weirdly. I now have this at the bottom of each post:

    Comment now �

    * Comments

    If the post has comments, I get this:

    1 Comment �

    * Comments

    I’m wondering if the prob was b/c I changed the code on 2 different files. Was I only supposed to change it in 1?

  5. peterb says:

    My guess is that when you copied/pasted from the text flow above, you picked up a carriage return, which is somehow confusing PHP.