WordPress Development Stack Exchange is a question and answer site for WordPress developers and administrators. Join them; it only takes a minute:

Sign up
Here's how it works:
  1. Anybody can ask a question
  2. Anybody can answer
  3. The best answers are voted up and rise to the top

I'm looking to create a function which would be called when the blog's /feed/?args... URL is requested. I've been looking at the_content_feed, would that be correct?

Also, how would I get the args in the URL into my function as an array?

share|improve this question
up vote 1 down vote accepted

It depends what you want to do as for when you want to hook into the process. the_content_feed is fired for each item in your feed, so this probably isn't the one you are after.

You could use pre_get_posts which fires just before WordPress queries the database:

add_action('pre_get_posts', 'catch_the_feed');

function catch_the_feed($query){

    if($query->is_main_query() && $query->is_feed()){
        //It's a feed!
        $variables = $query->query_vars;

untested but $variables should be an array of registered query varibles and their value (usually populated from what was recieved in the url).

...or you could use template_redirect which is when WordPress has retrieved the posts and is ready to display them (or redirect the user to a feed template)

share|improve this answer

Your Answer


By posting your answer, you agree to the privacy policy and terms of service.

Not the answer you're looking for? Browse other questions tagged or ask your own question.