WordPress.org

Ready to get started?Download WordPress

Forums

need hook to filter feed content (on output) (3 posts)

  1. jedharris
    Member
    Posted 4 years ago #

    I needed to make my wordpress markup paragraphs on my blog as div's, but mark them up as p's in my feed. (The div's render fine with the right style sheet, but feed readers will only render the content well with p's).

    I've successfully made WordPress do what I want, but at the cost of modifying the feed templates (feed-rss2 and feed-atom).

    The problem is that there's no filter hook that's called for feed content but not for normally displayed content. the_content is the hook called for both. Also, in the template, the content is actually echoed within the function the_content() rather than echoed in the template itself.

    My preferred solution would be to have a function that returns the content, and then echo it within the template. Right now I use get_the_content which works fine for my purposes, but I don't know what problems this might cause for others.

    Obviously I can continue to maintain my patched templates but I'd rather not.

  2. I needed to make my wordpress markup paragraphs on my blog as div's, but mark them up as p's in my feed.

    The problem is that there's no filter hook that's called for feed content but not for normally displayed content.

    I've only had two cups of coffee but try putting an is_feed() check in your function so that you can add_filter for the_content() when it's a feed but leave it alone for the other cases.

    Also the_content_rss() might work too but I can't recall why it didn't...

  3. cicloid
    Member
    Posted 4 years ago #

    Looking around for this same matter I believe what you are looking for is something like this:

    function myUniqueFeedFilter($query) {
    if ($query->is_feed) {
    $query->set('cat','-1');
    }
    return $query;
    }
    add_filter('pre_get_posts','myUniqueFeedFilter');

    I hope this helps you.

Topic Closed

This topic has been closed to new replies.

About this Topic