Posts

“Number of Comments” in XML feeds in Wordpress

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

  1. green la girl says on December 29th, 2006 at 10:01 pm:

    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 on December 29th, 2006 at 10:20 pm:

    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. green la girl says on December 30th, 2006 at 1:27 pm:

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

  4. green la girl says on December 30th, 2006 at 10:42 pm:

    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 on December 31st, 2006 at 11:04 am:

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

Leave a Reply





Archives and Links