Using WordPress ‘create_initial_theme_features()’ PHP function

The create_initial_theme_features() WordPress PHP function is used to create the initial theme features when the ‘setup_theme’ action is fired.

Usage

add_action('setup_theme', 'create_initial_theme_features');

In this example, the function create_initial_theme_features() is hooked to the ‘setup_theme’ action, which will trigger the creation of initial theme features when the theme is set up.

Parameters

  • This function does not accept any parameters.

More information

See WordPress Developer Resources: create_initial_theme_features

Examples

Triggering the Function with ‘setup_theme’ Action

// Hooks the function to 'setup_theme' action
add_action('setup_theme', 'create_initial_theme_features');

This will trigger the create_initial_theme_features() function when the ‘setup_theme’ action is fired, setting up the initial theme features.

Checking if Function Exists Before Hooking

// Checks if the function exists before hooking
if (function_exists('create_initial_theme_features')) {
add_action('setup_theme', 'create_initial_theme_features');
}

This ensures that the function create_initial_theme_features() exists before it’s hooked to the ‘setup_theme’ action.

Removing the Function from the ‘setup_theme’ Action

// Removes the function from the 'setup_theme' action
remove_action('setup_theme', 'create_initial_theme_features');

This will remove the create_initial_theme_features() function from the ‘setup_theme’ action, preventing the initial theme features from being created when the theme is set up.

Prioritizing the Function in the ‘setup_theme’ Action

// Sets priority of the function in the 'setup_theme' action
add_action('setup_theme', 'create_initial_theme_features', 5);

This will ensure that the create_initial_theme_features() function is triggered earlier when the ‘setup_theme’ action is fired.

Delaying the Function in the ‘setup_theme’ Action

// Delays the function in the 'setup_theme' action
add_action('setup_theme', 'create_initial_theme_features', 15);

This will ensure that the create_initial_theme_features() function is triggered later when the ‘setup_theme’ action is fired.