Using WordPress ‘get_theme_starter_content()’ PHP function

The get_theme_starter_content() WordPress PHP function expands a theme’s starter content configuration using core-provided data.

Usage

Here’s a generic example of how to use the function:

$starter_content = get_theme_starter_content();

Parameters

This function does not require any parameters.

More information

See WordPress Developer Resources: get_theme_starter_content()

Examples

Get Starter Content and Display the Output

This example retrieves the starter content and prints it as an array:

$starter_content = get_theme_starter_content();
echo '<pre>';
print_r($starter_content);
echo '</pre>';

Check for Specific Starter Content

This example checks if a specific widget area is part of the starter content:

$starter_content = get_theme_starter_content();

if (isset($starter_content['widgets']['sidebar-1'])) {
    echo '**Sidebar-1** is part of the starter content.';
} else {
    echo '**Sidebar-1** is not part of the starter content.';
}

Add New Widget Area to Starter Content

This example adds a new widget area to the starter content:

$starter_content = get_theme_starter_content();

$starter_content['widgets']['custom-sidebar'] = array(
    'search',
    'categories',
);

echo '<pre>';
print_r($starter_content);
echo '</pre>';

Modify Existing Starter Content

This example modifies an existing widget area in the starter content:

$starter_content = get_theme_starter_content();

if (isset($starter_content['widgets']['sidebar-1'])) {
    $starter_content['widgets']['sidebar-1'][] = 'custom-widget';
}

echo '<pre>';
print_r($starter_content);
echo '</pre>';

Remove Widget Area from Starter Content

This example removes a widget area from the starter content:

$starter_content = get_theme_starter_content();

if (isset($starter_content['widgets']['sidebar-1'])) {
    unset($starter_content['widgets']['sidebar-1']);
}

echo '<pre>';
print_r($starter_content);
echo '</pre>';