current_theme_supports()
Checks if the theme supports the specified feature, registered via add_theme_support().
For features that take arguments (e.g., 'html5' or 'custom-logo'), additional values can be passed to ensure that they are specifically supported.
Must be called after the theme support is declared, usually after the after_setup_theme hook.
Use the filter current_theme_supports-(feature) when you need to disable or enable support under certain conditions.
Hooks from the function
Returns
true|false. true if the theme supports the specified feature, otherwise false.
Usage
if( current_theme_supports( $feature ) ){
// feature $feature is enabled...
}
- $feature(string) (required)
Name of the feature to check. Available list:
- custom-header
- custom-background
- post-thumbnails
- automatic-feed-links
- post-formats
- menus
- editor-style
- widgets
- See the full list in the description of add_theme_support().
- ...$args(mixed)
Additional arguments for the specific feature that also need to be checked.
When a theme declares support for an option with sub-items, it passes an array of these sub-items:
add_theme_support( 'html5', [ 'comment-form', 'comment-list' ] );
The function behaves as follows:
-
Without arguments - it is sufficient that the html5 feature is supported:
current_theme_supports( 'html5' ); // true
-
With arguments - the function checks each passed sub-item. If at least one is not supported, it will return
false.truewill only be returned when all specified sub-items are supported.current_theme_supports( 'html5', 'comment-form' ); // true current_theme_supports( 'html5', 'search-form' ); // false current_theme_supports( 'html5', 'comment-form', 'search-form' ); // false
By default: none
-
Examples
#1 Demo
Let's check if the feature is enabled:
if( current_theme_supports('custom-header') ){
// Do something special if the custom-header feature is enabled...
}
Checking a specific argument of HTML5 support:
if ( current_theme_supports( 'html5', 'comment-form' ) ) {
// Load styles or execute logic that requires HTML5 markup for the comment form
}
Notes
- Global. Array.
$_wp_theme_features
Changelog
| Since 2.9.0 | Introduced. |
| Since 5.3.0 | Formalized the existing and already documented ...$args parameter by adding it to the function signature. |