Using WordPress ‘option_{$option}’ PHP filter

The option_{$option} WordPress PHP filter allows you to modify the value of an existing option before it’s returned.


add_filter('option_example_option', 'custom_function_name', 10, 2);

function custom_function_name($value, $option) {
    // your custom code here

    return $value;


  • $value (mixed): Value of the option. If stored serialized, it will be unserialized prior to being returned.
  • $option (string): Option name.

More information

See WordPress Developer Resources: option_{$option}


Change the site title

Modify the site title before it’s displayed on the frontend.

add_filter('option_blogname', 'change_site_title', 10, 2);

function change_site_title($value, $option) {
    $value = 'New Site Title';
    return $value;

Append text to the site description

Add custom text to the site description (tagline).

add_filter('option_blogdescription', 'append_text_to_description', 10, 2);

function append_text_to_description($value, $option) {
    $value .= ' - Custom Text';
    return $value;

Modify the default comment status

Change the default comment status for new posts to ‘closed’.

add_filter('option_default_comment_status', 'modify_default_comment_status', 10, 2);

function modify_default_comment_status($value, $option) {
    $value = 'closed';
    return $value;

Change the default category

Set the default category for new posts to a specific category ID.

add_filter('option_default_category', 'change_default_category', 10, 2);

function change_default_category($value, $option) {
    $value = 5; // Replace with your desired category ID
    return $value;

Modify the posts per page

Set the number of posts displayed per page to a specific value.

add_filter('option_posts_per_page', 'change_posts_per_page', 10, 2);

function change_posts_per_page($value, $option) {
    $value = 15;
    return $value;