• I’d like to be able to identify whether the current URI is not only a feed, but a specific feed — in my case a custom feed (i.e., ‘http://mysite.com/feed/custom’).

    is_feed() will check for a feed, however there are actions I want to take only on my custom feed.

    I’ve tried to identify the URI with $_SERVER['REQUEST_URI'], with no luck. That trick doesn’t seems to work with feeds, and I can’t tell why.

    Suggestions? Is there a way to target specific feeds?

    • This topic was modified 9 years, 4 months ago by Cory.
Viewing 2 replies - 1 through 2 (of 2 total)
  • Moderator bcworkz

    (@bcworkz)

    You could get the current query with get_queried_object(). The feed type should be in the “feed” query var. If the value is simply “feed”, then the request wants the default feed.

    There is a “do_feed_{$feed}” action where {$feed} is whatever value is in the feed query var. Thus the specific action will only fire if the request is for the feed named in the action tag. If you hook such an action, there’s no need to get the queried object as a check since the check is implicit in the action hook.

    Thread Starter Cory

    (@corypina)

    Thanks so much for this. I couldn’t get get_queried_object() to work for me — I might have been missing something. It did, however, send me on the right track.

    Instead I ended up using get_query_var( 'feed' ), and was able to access the data I needed.

    So, if I’m browsing a custom feed template at, for example, mysite.com/feed/custom, then the result of get_query_var( 'feed' ) will be custom.

    Thanks, again!

Viewing 2 replies - 1 through 2 (of 2 total)

The topic ‘Conditional check for custom RSS feed’ is closed to new replies.