Setting the language of RSS feed

Within the default feed template you’ll find something like this:

<language><?php bloginfo_rss( 'language' ); ?></language>

As you can see the bloginfo for the feed (bloginfo_rss()) is called (instead of get_bloginfo()). You can overwrite the feed language separately via a filter in your functions.php:

add_filter('bloginfo_rss', 'custom_rss_lang_attr', 10, 2);
function custom_rss_lang_attr($output, $show) {
  switch( $show ) {
    case 'language':
      $output="en-US";
      break;
  }
  return $output;
}

Update: As @toscho pointed out it’s bad practice to use a switch with just one case. Keep it simple and use an if statement:

add_filter('bloginfo_rss', 'custom_rss_lang_attr', 10, 2);
function custom_rss_lang_attr($output, $show) {
  if ( $show == 'language' ) {
    $output="en-US";
  }
  return $output;
}

Leave a Comment