The get_theme_feature_list() WordPress PHP function retrieves a list of WordPress theme features (also known as theme tags).
Usage
$theme_features = get_theme_feature_list($api);
Example:
$theme_features = get_theme_feature_list(true); print_r($theme_features);
Parameters
$api
(bool) (Optional) – Whether to try to fetch tags from the WordPress.org API. Defaults totrue
.
More information
See WordPress Developer Resources: get_theme_feature_list()
Examples
Display All Theme Features
This example retrieves and displays all theme features.
$theme_features = get_theme_feature_list(true); foreach ($theme_features as $feature) { echo '- ' . $feature . '<br>'; }
Display Theme Features in a Dropdown
This example retrieves theme features and populates a dropdown menu with the feature names.
$theme_features = get_theme_feature_list(true); echo '<select name="theme_features">'; foreach ($theme_features as $feature) { echo '<option value="' . $feature . '">' . $feature . '</option>'; } echo '</select>';
Display Theme Features in a Checkboxes List
This example retrieves theme features and creates a list of checkboxes with the feature names.
$theme_features = get_theme_feature_list(true); foreach ($theme_features as $feature) { echo '<input type="checkbox" name="theme_features[]" value="' . $feature . '"> ' . $feature . '<br>'; }
Get Theme Features without API
This example retrieves theme features without using the WordPress.org API.
$theme_features = get_theme_feature_list(false); print_r($theme_features);
Count Theme Features
This example retrieves theme features and displays the total count.
$theme_features = get_theme_feature_list(true); $theme_features_count = count($theme_features); echo 'Total Theme Features: ' . $theme_features_count;