• Is there a way to exclude a certain DIV class from going out with the RSS feed? I’m including a kind of magazine-style pullout quote in my posts that basically repeats some piece (or pieces) of the post content to make them stand out on the side. The problem is that if this repeated content goes out with the RSS feed, it just looks like an extra paragraph of unnecessary text. So, basically, I’m looking for a display:none equivalent for what goes into the RSS feed.

Viewing 9 replies - 1 through 9 (of 9 total)
  • It would be simple (well!) to roll a plugin that removes this div from your feed’s content.

    Post an example of the div class, and I’ll put something together for you.

    Thread Starter ptvguy

    (@ptvguy)

    Thanks, Kafkaesqui. Here’s what the code looks like when I place it in a post.

    <div class="shoutout">
    <p>
    ...this is some example text...
    </p>
    </div>

    Some posts have several “shoutouts” and some have only one. I don’t think you’ll need the CSS for it, but I’ll post it for anyone who may be looking through the forum one day to figure out how to do this.

    .shoutout {
    float: right;
    width: 155px;
    margin-top: 10px;
    margin-right: 15px;
    padding: 0;
    }

    .shoutout p {
    font-family: "Trebuchet MS", Verdana, Arial, Helvetica, sans-serif;
    font-size: x-large;
    text-align: right;
    width: 150px;
    }

    By the way, I for one think that such a plugin could be quite useful. RSS feeds are (usually) presented as linear text even if the page formatting presents it differently.

    And here’s what I’ve come up with…

    Exclude DIV from RSS plugin:
    Download plugin | View source

    The class (or id) attribute value for the div is defined through the $class_id variable, which is set by default in the plugin to “shoutout”.

    Did some testing but of course only real world banging will show up potential bugs in my pattern matching.

    Thread Starter ptvguy

    (@ptvguy)

    Awesome work, Kaf. I tried it out on my blog, and it did exactly what I needed. I went to my RSS reader prior to installing it and brought up my feed–which, of course, included my “shoutouts.” Then, after installing it, I refreshed the feed and they were all gone. Thank you very much. I knew that it was something simple, but I have no experience with the coding for the WordPress hooks.

    I think that it’s worth releasing as a regular plugin. It has potential to be extremely useful. Here are some possible notes for public release:

    • Needs an admin interface to allow for resetting the $class_id outside the code itself.
    • Probably doesn’t need to check for the DIV in the excerpt part.
    • Might want to expand for other identified elements such as SPAN.
    • Needs a spiffy plugin name like ClassBlocker or NoClassFeed. ;>

    Anyway, thanks again for your time and expertise.

    * Needs an admin interface to allow for resetting the $class_id outside the code itself.

    I’m not a fan of plugins with single setting option pages. But if I do take it *more* public, I’ll certainly look at ways of expanding the feature set, which would require a number of settings to play with.

    * Probably doesn’t need to check for the DIV in the excerpt part.

    Actually it does — at least, to my way of thinking. Most probably do not provide an excerpt and allow WordPress to take it from the content. And in the event part or all of a div is displayed with the excerpt, it could be confusing since it would not even be blocked off by the div (tags having been stripped from the excerpt).

    In any case, it certainly doesn’t hurt anything running on the excerpt.

    * Might want to expand for other identified elements such as SPAN.

    Checked for expanding that options page.

    * Needs a spiffy plugin name like ClassBlocker or NoClassFeed. ;>

    We’ll see…

    Thread Starter ptvguy

    (@ptvguy)

    Please don’t construe my previous comments as a complaint of any kind. I’m more than happy with the plugin as is. I actually expected to get raw code that I would have to integrate into the PHP myself. You made it incredibly easy, and I truly appreciate that.

    Please don’t construe my previous comments as a complaint of any kind.

    Not at all! I understood it to be constructive feedback, something I always like to get.

    Very useful plugin, exactly what I’ve been looking for. Thanks a lot!

    Just what I need. ?? Only I’m using span instead of div; I’ve tweaked the code to account for this myself, but a better solution would be adding another variable that lets you specify an element to exclude, or if left blank filter everything.

Viewing 9 replies - 1 through 9 (of 9 total)
  • The topic ‘Exclude DIV from RSS’ is closed to new replies.