I have a rss feed for my demo blog here.


It passes the 'user' variable 'john' into the feed posts.

I need to add the 'user' variable to the link.

Note - I had to replace my domain with 'websiteurl' below as this site wouldn't let me post more than 1 link as new user



websiteurl/this-is-a-test-2/john websiteurl/this-is-a-test-2?user=john

Please can someone tell me what I need to change in the function.php or feed.php files.


  • How does your site pass "the 'user' variable 'john' into the feed posts" Post that code, please. – s_ha_dum Jan 18 '13 at 15:15

add the following to your functions.php file:

add_filter('feed_link','my_site_feed', 10, 2);
function my_site_feed($url, $feed_type ){
    $user = my_get_the_username(); //this function should return the username.
    return add_query_arg( array('user' => $user ), $url );

And get your rss feed url using:

echo get_bloginfo('rss2_url');


  • Thanks - but I John is a variable. I added the following code - WILL IT WORK? add_filter( 'query_vars', 'addnew_query_vars', 10, 1 ); function addnew_query_vars($vars) { $vars[] = 'user'; // var1 is the name of variable you want to add return $vars; } add_filter('feed_link','my_site_feed', 10, 2); function my_site_feed($url, $feed_type ){ return add_query_arg( array('user' => '$vars' ), $url ); } – Dom Bowkett Jan 18 '13 at 12:37
  • I don't think you need to filter query_vars and at any rate, that's the wrong filter ;) if John is a variable then you just need to add it within the my_site_feed() function. I've updated my answer to reflect this. – WP Themes Jan 18 '13 at 14:01

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service, privacy policy and cookie policy

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