• Resolved bcreighton

    (@bcreighton)


    Hi –

    I’m trying to keep the html (including img tags) in my RSS feed. I have it set to full text in options. In the wp-rss2.php template I have this set:

    <?php if ( strlen( $post->post_content ) > 0 ) : ?>
    <description><![CDATA[<?php the_content_rss('(more...)', FALSE, '', 50, 0); ?>]]></description>

    However… it still strips it out even though encode_html is set to 0.

    Any ideas?

    Thanks!

Viewing 4 replies - 1 through 4 (of 4 total)
  • What version of WordPress are you running? In the current version (2.0.5), this is what those lines in wp-rss2.php look like:

    <?php if ( strlen( $post->post_content ) > 0 ) : ?>
    <content:encoded><![CDATA[<?php the_content('', 0, '') ?>]]></content:encoded>

    There’s no need of the_content_rss() here; having the post content display (through use of the_content()) inside the CDATA section protects it from XML parsers. So if you made the modification, there was no need to do so.

    Thread Starter bcreighton

    (@bcreighton)

    You’re right – it does work with content:encoded. I have a bit of an issue using it because I’m pulling in the rss elsewhere using PHP 5’s SimpleXML and the “:” in content:encoded is messing up the syntax.

    echo $item->content:encoded;

    Hmmm…

    Thread Starter bcreighton

    (@bcreighton)

    Figured it out! For those interested:

    $rss = simplexml_load_file($url);
    $content = $rss->channel->item->children( "https://purl.org/rss/1.0/modules/content/" );
    foreach ($rss->channel->item as $item) {
    echo $content->encoded;
    }

    This is close to what I’m looking for, but where do I put that snippit?

    I’m more confused than I need to be right now…I’m sure.

Viewing 4 replies - 1 through 4 (of 4 total)
  • The topic ‘Keep HTML in RSS feed?’ is closed to new replies.