Using WordPress ‘populate_options’ PHP action

The populate_options WordPress PHP action fires before creating WordPress options and populating their default values.


add_action('populate_options', 'your_custom_function');
function your_custom_function() {
    // Your custom code here


  • None

More information

See WordPress Developer Resources: populate_options


Add a custom option with default value

Add a custom option called my_custom_option with a default value of Hello, World!.

add_action('populate_options', 'add_my_custom_option');
function add_my_custom_option() {
    add_option('my_custom_option', 'Hello, World!');

Change default values of existing options

Modify the default values of the blogname and blogdescription options.

add_action('populate_options', 'change_default_blog_options');
function change_default_blog_options() {
    update_option('blogname', 'My New Blog');
    update_option('blogdescription', 'A fantastic new blog');

Set default timezone

Set the default timezone for the WordPress site.

add_action('populate_options', 'set_default_timezone');
function set_default_timezone() {
    update_option('timezone_string', 'America/New_York');

Enable default theme features

Enable default theme features such as post thumbnails and custom header.

add_action('populate_options', 'enable_default_theme_features');
function enable_default_theme_features() {

Set the default permalink structure to a custom format.

add_action('populate_options', 'set_default_permalink_structure');
function set_default_permalink_structure() {
    update_option('permalink_structure', '/%year%/%monthnum%/%postname%/');