Using WordPress ‘current_theme_supports-{$feature}’ PHP filter

The current_theme_supports-{$feature} WordPress PHP filter checks if the active theme supports a specific feature.

Usage

add_filter('current_theme_supports-{$feature}', 'my_custom_function', 10, 3);

function my_custom_function($supports, $args, $feature) {
    // Your custom code here
    return $supports;
}

Parameters

  • $supports (bool): Whether the active theme supports the given feature. Default true.
  • $args (array): Array of arguments for the feature.
  • $feature (string): The theme feature.

More information

See WordPress Developer Resources: current_theme_supports-{$feature}

Examples

Check for post-thumbnails support

Check if the theme supports post-thumbnails and disable it.

add_filter('current_theme_supports-post-thumbnails', 'disable_post_thumbnails', 10, 3);

function disable_post_thumbnails($supports, $args, $feature) {
    // Disable post-thumbnails support
    return false;
}

Enable custom-logo support

Enable custom-logo support with specific width and height.

add_filter('current_theme_supports-custom-logo', 'enable_custom_logo', 10, 3);

function enable_custom_logo($supports, $args, $feature) {
    // Enable custom-logo support with custom dimensions
    $args['width'] = 200;
    $args['height'] = 100;
    return true;
}

Disable custom-background support

Disable custom-background support for the theme.

add_filter('current_theme_supports-custom-background', 'disable_custom_background', 10, 3);

function disable_custom_background($supports, $args, $feature) {
    // Disable custom-background support
    return false;
}

Add custom-header support

Add custom-header support with specific width and height.

add_filter('current_theme_supports-custom-header', 'add_custom_header', 10, 3);

function add_custom_header($supports, $args, $feature) {
    // Add custom-header support with custom dimensions
    $args['width'] = 1200;
    $args['height'] = 600;
    return true;
}

Enable HTML5 support

Enable HTML5 support for specific elements.

add_filter('current_theme_supports-html5', 'enable_html5_support', 10, 3);

function enable_html5_support($supports, $args, $feature) {
    // Enable HTML5 support for specific elements
    $args[] = 'comment-list';
    $args[] = 'comment-form';
    $args[] = 'search-form';
    return true;
}