The alloptions WordPress PHP filter allows you to modify all options retrieved from the database.
Usage
add_filter('alloptions', 'your_custom_function_name');
function your_custom_function_name($alloptions) {
// your custom code here
return $alloptions;
}
Parameters
$alloptions: (array) An array containing all the options retrieved from the database.
More information
See WordPress Developer Resources: alloptions
Examples
Change site title
Modify the site title by appending ” – Custom”:
add_filter('alloptions', 'change_site_title');
function change_site_title($alloptions) {
$alloptions['blogname'] .= ' - Custom';
return $alloptions;
}
Disable comments globally
Disable comments for all posts and pages:
add_filter('alloptions', 'disable_comments_globally');
function disable_comments_globally($alloptions) {
$alloptions['default_comment_status'] = 'closed';
return $alloptions;
}
Change default category
Change the default category for new posts to a specific ID (e.g., 10):
add_filter('alloptions', 'change_default_category');
function change_default_category($alloptions) {
$alloptions['default_category'] = 10;
return $alloptions;
}
Modify upload path
Change the default upload path to a custom directory (e.g., ‘custom-uploads’):
add_filter('alloptions', 'modify_upload_path');
function modify_upload_path($alloptions) {
$alloptions['upload_path'] = 'custom-uploads';
return $alloptions;
}
Set a custom date format
Set a custom date format for the site (e.g., ‘Y-m-d’):
add_filter('alloptions', 'set_custom_date_format');
function set_custom_date_format($alloptions) {
$alloptions['date_format'] = 'Y-m-d';
return $alloptions;
}