Update RSS Language Value

WordPress-Christmas-13And today opens the 13th door of our Advent Calendar. You cannot only use a language key for your blog, but also for your feed:<language>en</language>. WordPress also has provided an option, but not easy to maintain.
However, it is advisable to use the key according to the codec and therefore I show you some ways.

Via database

Search directly in your data base for the key (option_name) rss_language and maintain the value of your language, for example de. You can find the key values on this page.

Via Hook

Alternatively you can do it with a function of WordPress. You just have to put the following syntax in the functions.php of your theme and a call of the admin or frontend is enough; it's enough to set the value once. After that you can remove the code from your template.

function update_rss_language() {
	update_option( 'rss_language', 'de' );
}
add_action( 'admin_init', 'update_rss_language' );

Comfortable in the settings

The last possibility is a little more comfortable and puts another field in the General - Reading area. There is another field, which allows to maintain the value.
wp-rss-language

You have to put the following code in a Plugin or in the functions.php of your active theme.

function rss_language_string() {
	?>
	<input name="rss_language" type="text" id="rss_language" value="<?php form_option('rss_language'); ?>" class="regular-text" />
	<span class="description"><?php _e('RSS supports multiple languages through the language element, which contains a short code that identifies that the natural language employed in the channel. See on this table for your <a href="http://www.rssboard.org/rss-language-codes#table">language codes</a>.'); ?></span>
	<?php
}

function rss_language_admin_init() {
	register_setting( 'reading', 'rss_language' );
	add_settings_field( 'rss_language', __('RSS Language Code'), 'rss_language_string', 'reading');
}
add_action( 'admin_init', 'rss_language_admin_init' );

Comments are closed.

2 comments

  1. Dion Hulse (dd32)

    A faster way to set it once, Is to use WordPress's option.php page:

    1.open /wp-admin/options.php
    2. scroll down to rss_language
    3. Change the value
    4. Scroll to the bottom and hit save changes.

  2. Frank

    Yes, you are right - we have also a door on the advent calendar with this tip. Thanks for reading WP Engineer!