How to work out the feed type that the_content/the_excerpt is being invoked in?
-
tl;dr version: How can I determine the type of feed and the current post/page context for
the_excerpt
andthe_content
when invoked in response to a feed?More detailed version …
When coding a filter hook for
the_content
orthe_excerpt
, the WordPress API gives me relatively fine grained control over the type of post or page being handled via theis_*
series of template tags …is_front_page()
,is_archive()
and so on.In one of my plugins, all of this allows me to offer a very flexible set of configuration options for when to add and when not to add …. stuff … to a post or page’s content or excerpt. As I can detect the type of post/page and the context that
the_content
orthe_excerpt
is being invoked in I do do things along the lines of add stuff to the excerpt and the content if being displayed on the front page or in category archives or on pages but don’t add stuff anywhere else.What I can’t work out is how to determine the type of feed that
the_content
and/orthe_excerpt
is being invoked in. I can detect a feed in general viais_feed()
but that’s as far as I can work this out. Moreover, whenis_feed()
returnstrue
within the context of a feed, all the otheris_*
template tags (seem to) returnfalse
.As a result I can’t determine if, for example,
the_content
is being invoked in the context of a feed for the front page, or a feed for a category archive, or so on.Is this even possible, or am I just overlooking something? Much general Googling, Googling of the Codex and searching through the WordPress StackExchange has proved unsuccessful, so far.
-Gary
- The topic ‘How to work out the feed type that the_content/the_excerpt is being invoked in?’ is closed to new replies.