2

What is the simplest / easiest way to set up the language of the rss feed. Currently, that field in my feed xml is blank, it looks like this

 <language></language>

and i would like it to look like

<language>en-US</language>

Any help on how to easily implement it?

3

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;
}
| improve this answer | |
  • What is the reason for that lonely switch statement? – fuxia Aug 26 '14 at 2:49
  • Great reply! Thanks. Also, is it a good idea to force higher update period and / or frequency? The default is update period == hour and update frequency == 1 – idjuradj Aug 26 '14 at 11:30
  • @Nicholas This depends on your personal preferences and the amount of content you can provide. It probably doesn't make sense to update the feed if there is no new content. – Sven Aug 26 '14 at 11:42

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.