The blog_option_{$option} WordPress PHP filter allows you to modify a blog option value. The dynamic part of the filter, $option, refers to the blog option name.
Usage
add_filter('blog_option_example_option', 'modify_blog_option_value', 10, 2);
function modify_blog_option_value($value, $id) {
// Your custom code here
return $value;
}
Parameters
- $value (string): The option value.
- $id (int): Blog ID.
More information
See WordPress Developer Resources: blog_option_{$option}
Examples
Change blog name
Modify the blog name by appending a custom text.
add_filter('blog_option_blogname', 'modify_blog_name', 10, 2);
function modify_blog_name($value, $id) {
$value .= ' - Custom Text';
return $value;
}
Change the blog description
Update the blog description by adding extra information.
add_filter('blog_option_blogdescription', 'modify_blog_description', 10, 2);
function modify_blog_description($value, $id) {
$value .= ' - Extra Information';
return $value;
}
Set a default blog language
Set a default blog language if the blog language is not set.
add_filter('blog_option_WPLANG', 'set_default_language', 10, 2);
function set_default_language($value, $id) {
if (empty($value)) {
$value = 'en_US';
}
return $value;
}
Force the blog to be private
Force the blog to always be private by changing the blog_public option.
add_filter('blog_option_blog_public', 'force_private_blog', 10, 2);
function force_private_blog($value, $id) {
return 0; // Set the blog to private
}
Modify the blog’s time zone
Change the blog’s time zone to a specific time zone.
add_filter('blog_option_timezone_string', 'modify_timezone', 10, 2);
function modify_timezone($value, $id) {
$value = 'America/New_York'; // Set the time zone to New York
return $value;
}