current_theme_supports( string $feature, mixed $args ): bool
- Since
- 2.9.0, 5.3.0
- Source
wp-includes/theme.php:3159
Determines whether the active theme has declared support for a named feature registered via add_theme_support(). It accepts extra arguments for features like post-thumbnails, post-formats, html5, custom-logo, custom-header and custom-background that were registered with a specific type or capability. When no extra arguments are given it returns true as soon as the feature exists at all, without checking any registered subtype, so pass the type or capability you actually care about to get a meaningful result.
Description
Example usage:
current_theme_supports( 'custom-logo' );
current_theme_supports( 'html5', 'comment-form' );Compatibility
- WordPress
- since 5.3.0
- PHP
- 7.4–8.6-dev
- 6.7.7
- 6.8.8
- 6.9.7
- 7.0.4
- 7.1.0
Present in every tracked release (6.7.7 to 7.1.0), and compiles on PHP 7.4 through 8.6-dev.
Parameters
$featurestring- The feature being checked. See add_theme_support() for the list of possible values.
$argsmixed- Optional extra arguments to be checked against certain features.
Return value
bool- True if the active theme supports the feature, false otherwise.
Code examples
Every example is editable and runs in a real WordPress booted in your browser by WordPress Playground. Press Run, then edit the code: clicking away re-runs it. Nothing is sent anywhere until you do.
Check whether a theme feature supports a specific post type
Register post thumbnail support for two post types, then confirm which ones report support.
add_theme_support( 'post-thumbnails', array( 'post', 'page' ) );
$supports_page = current_theme_supports( 'post-thumbnails', 'page' );
$supports_attachment = current_theme_supports( 'post-thumbnails', 'attachment' );
echo 'Pages support thumbnails: ' . esc_html( $supports_page ? 'yes' : 'no' ) . "\n";
echo 'Attachments support thumbnails: ' . esc_html( $supports_attachment ? 'yes' : 'no' ) . "\n";If add_theme_support() had been called with no array (support for every type), current_theme_supports() would return true for any post type without checking the list.
Check whether a specific post format is registered
Register two custom post formats and confirm which one the active theme reports support for.
add_theme_support( 'post-formats', array( 'aside', 'gallery' ) );
$supports_aside = current_theme_supports( 'post-formats', 'aside' );
$supports_video = current_theme_supports( 'post-formats', 'video' );
echo 'Aside format supported: ' . esc_html( $supports_aside ? 'yes' : 'no' ) . "\n";
echo 'Video format supported: ' . esc_html( $supports_video ? 'yes' : 'no' ) . "\n";Common problems and fixes · 4
- Why does current_theme_supports() return false right after I call add_theme_support()?
- Why does checking a feature always return true even though I only registered it for certain post types?
- Why does current_theme_supports('custom-header-uploads') give a strange result?
- Can a plugin override what current_theme_supports() reports for a feature?
Why does current_theme_supports() return false right after I call add_theme_support()?
Why does checking a feature always return true even though I only registered it for certain post types?
Why does current_theme_supports('custom-header-uploads') give a strange result?
Can a plugin override what current_theme_supports() reports for a feature?
Alternatives and related functions
add_theme_support- When you need to register that the theme supports a feature in the first place, since current_theme_supports() only reads what add_theme_support() has already recorded.
get_theme_support- When you need the actual arguments registered for a feature (such as the array of supported post types) rather than a plain true or false answer.
remove_theme_support- When a child theme or plugin needs to unregister a feature the parent theme declared, so later current_theme_supports() calls return false for it.
Performance profile
How much work a call to current_theme_supports() does, and what it touches: the algorithmic scaling, the Zend instruction count per call across PHP versions, the hooks it hands control to, and the core code that calls it. Measured from the compiled opcodes, not a stopwatch, so every number is identical on any machine running the same PHP version, and every function in core is ranked by cost.
- Cost class
- Trivial
- Scaling
- Constant
- Instructions
- 8–32
- Plugin surface
- 1 hook
- Called by
- 50
Touches nothing outside its own arguments.
No loop in the body: the same number of instructions runs whatever you pass in.
Executed per call on PHP 8.5, depending on the branch taken. The body compiles to 75.
Third-party callbacks on 'current_theme_supports-{$feature}' run inside this call, and their cost is not bounded by anything here.
50 places in core call this, so the cost is paid more often than your own code shows.
What it touches
- hookthird-party callbacks
apply_filters()called directly
What one call costs · 3 distinct outcomes
One number would be a lie: the work depends on which branch runs. These are every distinct cost current_theme_supports() can have, taken from its control-flow graph on PHP 8.5.
| When | Instructions | Calls it makes |
|---|---|---|
$feature !== "custom-header-uploads" | 8–32 | none |
$feature === "custom-header-uploads" | 10 | current_theme_supports() |
$feature !== "custom-header-uploads" && isset($_wp_theme_features[$feature]) | 18–32 | apply_filters() |
Across PHP versions
| PHP | Compiled | Executed | Branches | Notes |
|---|---|---|---|---|
| 8.6-dev | 75 | 8–32 | 12 | |
| 8.5 | 75 | 8–32 | 12 | |
| 8.4 | 75 | 8–32 | 12 | 6 fewer instructions than PHP 8.3 |
| 8.3 | 81 | 8–32 | 12 | |
| 8.2 | 81 | 8–32 | 12 | 1 more instruction than PHP 8.1 |
| 8.1 | 80 | 8–33 | 12 | |
| 7.4 | 80 | 8–33 | 12 |
An instruction is not a fixed amount of time, so a matching count is not necessarily the same speed; what it rules out is a difference in the work itself.
Hooks and filters fired · 2
2 hooks fire while current_theme_supports() runs, in this order:
- apply_filters( current_theme_supports-{$feature} )filterline 3173 (+14 into the body)
Filters whether the active theme supports a specific feature.
- apply_filters( current_theme_supports-{$feature} )filterline 3219 (+60 into the body)
Filters whether the active theme supports a specific feature.
Uses · 2
- current_theme_supports()Checks a theme's support for a given feature.
- apply_filters()Calls the callback functions that have been added to a filter hook.
Used by · 50
- Custom_Background::admin_page()Displays the custom background page.
- Custom_Image_Header::ajax_header_crop()Gets attachment uploaded by Media Manager, crops it, then saves it as a new object. Returns JSON-encoded object details.
- Custom_Image_Header::css_includes()Sets up the enqueue for the CSS files.
- Custom_Image_Header::get_header_dimensions()Calculates width and height based on what the currently selected theme supports.
- Custom_Image_Header::js()Executes JavaScript depending on step.
- Custom_Image_Header::js_1()Displays JavaScript based on Step 1 and 3.
- Custom_Image_Header::js_2()Displays JavaScript based on Step 2.
- Custom_Image_Header::js_includes()Sets up the enqueue for the JavaScript files.
- Custom_Image_Header::step_1()Displays first step of custom header image page.
- Custom_Image_Header::step_2()Displays second step of custom header image page.
- Custom_Image_Header::step_3()Displays third step of custom header image page.
- WP_Admin_Bar::initialize()Initializes the admin bar.
Show all 50
- WP_Customize_Header_Image_Control::render_content()Renders the control's content.
- WP_Customize_Manager::register_controls()Registers some default controls.
- WP_Customize_Nav_Menu_Locations_Control::content_template()JS/Underscore template for the control UI.
- WP_Customize_Nav_Menus::available_item_types()Returns an array of all the available item types.
- WP_Customize_Nav_Menus::customize_register()Adds the customizer settings and controls.
- WP_Customize_Panel::check_capabilities()Checks required user capabilities and whether the theme has the feature support required by the panel.
- WP_Customize_Section::check_capabilities()Checks required user capabilities and whether the theme has the feature support required by the section.
- WP_Customize_Setting::check_capabilities()Validate user capabilities whether the theme supports the setting.
- WP_Customize_Widgets::customize_dynamic_partial_args()Filters arguments for dynamic widget partials.
- WP_Customize_Widgets::get_selective_refreshable_widgets()List whether each registered widget can be use selective refresh.
- WP_Customize_Widgets::get_setting_args()Retrieves common arguments to supply when constructing a Customizer setting.
- WP_Customize_Widgets::selective_refresh_init()Adds hooks for selective refresh.
- WP_Nav_Menu_Widget::widget()Outputs the content for the current Navigation Menu widget instance.
- WP_Posts_List_Table::inline_edit()Outputs the hidden row displayed when inline editing
- WP_REST_Attachments_Controller::handle_featured_media()Determines the featured media based on a request param.
- WP_REST_Themes_Controller::prepare_item_for_response()Prepares a single theme output for response.
- WP_Theme::get_post_templates()Returns the theme's post templates.
- WP_Theme_JSON::get_layout_styles()Gets the CSS layout rules for a particular block from theme.json layout definitions.
- WP_Theme_JSON_Resolver::get_theme_data()Returns the theme's data.
- WP_Widget_Archives::widget()Outputs the content for the current Archives widget instance.
- WP_Widget_Categories::widget()Outputs the content for the current Categories widget instance.
- WP_Widget_Meta::widget()Outputs the content for the current Meta widget instance.
- WP_Widget_Pages::widget()Outputs the content for the current Pages widget instance.
- WP_Widget_RSS::widget()Outputs the content for the current RSS widget instance.
- WP_Widget_Recent_Comments::recent_comments_style()Outputs the default styles for the Recent Comments widget.
- WP_Widget_Recent_Comments::widget()Outputs the content for the current Recent Comments widget instance.
- WP_Widget_Recent_Posts::widget()Outputs the content for the current Recent Posts widget instance.
- WP_Widget_Tag_Cloud::widget()Outputs the content for the current Tag Cloud widget instance.
- _add_default_theme_supports()Adds default theme supports for block themes when the 'after_setup_theme' action fires.
- _add_template_loader_filters()Adds necessary hooks to resolve '_wp-find-template' requests.
- _custom_header_background_just_in_time()Registers the internal custom header and background routines.
- _custom_logo_header_styles()Adds CSS to hide header text for custom logo, based on Customizer setting.
- _get_random_header_data()Gets random header image data from registered images in theme.
- _wp_get_iframed_editor_assets()Collect the block editor assets that need to be loaded into the editor's iframe.
- _wp_render_title_tag()Displays title tag with content.
- build_template_part_block_instance_variations()Returns an array of instance variation objects for the template part block
- comment_form()Outputs a complete commenting form for use within a template.
- create_initial_taxonomies()Creates the initial taxonomies.
Changelog
Introduced in 2.9.0. Unchanged from 6.7.7 through 7.1.0.
Signature, return type and hooks compared across 5 parsed releases.
...$args parameter by adding it to the function signature.from the docblockAbout this page
- Parsed data
- Generated from the wordpress-develop 7.1.0 tag, from
src/wp-includes/theme.php, and regenerated for each WordPress release so it tracks the code rather than a snapshot of it. - Corrections
- Something wrong on this page? Report it and it gets fixed in the next regeneration.