WordPress.org

Ready to get started?Download WordPress

Forums

Need Help: Adding CSS to RSS2.0 feeds (11 posts)

  1. RaynerApe
    Member
    Posted 9 years ago #

    I am looking for any help to hack the RSS functions of WordPress so I can include remote CSS file into RSS so aggregators such as FeedDemon use it to provide design similar to my webpage. This website has info on Movable Type hack, but I know little of PHP and can't translate this to WordPress myself. Thanks in advance for any help and pointers how to do it.

    http://www.crystalflame.net/2003/12/rss_with_css.html

  2. Lorelle
    Member
    Posted 9 years ago #

    I see there isn't an answer, and I've been watching this. I'd love to know HOW and if it is possible to do this, too.

  3. Kafkaesqui

    Posted 9 years ago #

    First let me say I consider this sort of thing a bastardization of the format, and do not endorse it. Now that that's out of the way...

    For RSS 2.0 you want to edit the wp-rss2.php file (in your blog's root directory). Towards the end you'll find this section:

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

    I assume you're providing full feeds (a given for what you're doing here), so you only need to hit the first <content:encoded> tag. Replace that line with:

    <content:encoded><![CDATA[<link rel="stylesheet" href="<?php bloginfo('siteurl'); ?>/site.css" type="text/css" title="styled" />
    <?php the_content('', 0, '') ?>]]></content:encoded>

    For RDF/RSS 1 (wp-rdf.php), the alteration is exactly the same as for RSS 2. Just look near the very end for this line:

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

    Make the same change as shown above for RSS 2.

    Atom is quite different. Look for this line (round about the middle) in wp-atom.php:

    <link rel="alternate" type="text/html" href="<?php permalink_single_rss() ?>" />

    and add your stylesheet link tag just below it on a new line.

    Stylesheet notes: If you're using the primary stylesheet from your active theme (i.e. style.css), use this for the href value:

    href="<?php bloginfo('stylesheet_url'); ?>"

    If it's part of your theme but not the default stylesheet:

    href="<?php bloginfo('stylesheet_directory'); ?>/rss-style.css"

  4. Lorelle
    Member
    Posted 9 years ago #

    Thanks for the info, but I don't understand the bastardization issue. This is totally new for me.

    In my case, I have a picture in the excerpt of many of my "posts" and that goes into the feed. I've seen feeds where the graphics are floated to the left or right and not sitting on "top" of the text, like mine. I don't want to change the whole RSS going out, I just would like the picture to float on one side or the other of the text so it doesn't look so awful.

    I didn't know there was an agenda on RSS output. It's a new concept for me, though I've been using RSS for ages from other sites, I've not had to deal with it coming from mine.

    The things we all need to learn ;-)

  5. Kafkaesqui

    Posted 9 years ago #

    The initial comment was an attempt to retain my street cred, Lorelle. Can't let the standards Illuminati crowd know I'm gleefully helping others play on the fringes of The Right Way To Do Things™......

    Must I put smilies in every post to denote comedy? :)

    On a serious note, RSS was intended as a content syndication format, and for it content is King (yep, capital K and all). Now it's easy to make the argument that images are part of that content, and even (to a degree) the placement of those images is important to it. But death by papercuts is still a death, and I certainly don't have to spend time convincing anyone that some time soon they can start expecting full-blown sites in all their layout glory clogging up their syndi reader. At that point I have to ask, why even visit your site anymore?

  6. Lorelle
    Member
    Posted 9 years ago #

    True. Thanks for the chiding and the siding. We is just all trying to understand all this complicated new stuffings and all the rules. You guide us wisely, old faithful master to all things of The Right Way To Do Things...and we bow to your eternal wisdom......

  7. vkaryl
    Member
    Posted 9 years ago #

    Isn't the point of an RSS feed just to "whet the appetite" and provide a link to the relevant (with CSS) post? I could be wrong, I don't mess with it, but if that's the point, then why is it at all necessary to provide anything to a feed other than an appetite whetting snippet of information?

    Of course, if you're lazy, a hunk of your presumably gorgeous site-look or a graphic might save you doing some mental "legwork". But still, seems to me it's like seeing a nude woman for the hundredth or thousandth time - what's the big deal? but if all you see is peek-a-boo....

  8. Kafkaesqui

    Posted 9 years ago #

    "But still, seems to me it's like seeing a nude woman for the hundredth or thousandth time - what's the big deal? but if all you see is peek-a-boo...."

    Possibly the best analogy for site syndication I have seen, ever.

  9. vkaryl
    Member
    Posted 9 years ago #

    Um. Thanks, Kafka - I think. True though - you really want to just feed (points to whoever thought up that use for the whole system, I think!) the viewer enough to turn her into a click-the-link reader. This is what print news has been doing (or trying to) for hundreds of years.

    It's exactly the same as a bold-72point headline: it screams "more! you want MORE!" A tease is perfect. Anything more is superfluous, gratuitous, and self-defeating....

  10. RaynerApe
    Member
    Posted 9 years ago #

    Thank you all for posting valuable information and hack to make this possible!

  11. Jeremy Clarke
    Member
    Posted 8 years ago #

    Just a note that the use of RSS as an promotional mechanism (i.e. in the way that BBC and Wired News use it) is only one of it's potential values. It is also very useful as a way of letting people that you've posted at all (if you're infrequent with updates) and best of all as a full reading solution.

    As nice as I'm sure your designs are, they are the same everytime anyway, so why force yoru reader to constantly load it in their browser along with all the images on posts they've seen already etc. I have dozens of feeds in my reader that i just read there (boingboing is a really popular example). It's a thousand times more convenient as I only have to load posts i haven't read yet (it feels kind of like email) and I can quickly move through all the content.

    The partial clips are really more for sites that demand clicks to get ad revenue (though there's also ways to get ads into the feed itself, though they are a bit rudimentary, http://www.engadget.com/rss.xml engadget has a good example of that.

Topic Closed

This topic has been closed to new replies.

About this Topic

Tags

No tags yet.