Using add_theme_support inside a plugin

There are comments in core code that this should be improved, but they are there for a while already. Basically there is no native function to add or remove part of some feature, only feature altogether.

Doing it manually would be running something like this after theme is done (late on after_setup_theme hook):

function add_thumbnails_for_cpt() {

    global $_wp_theme_features;

    if( empty($_wp_theme_features['post-thumbnails']) )
        $_wp_theme_features['post-thumbnails'] = array( array('your-cpt') );

    elseif( true === $_wp_theme_features['post-thumbnails'])
        return;

    elseif( is_array($_wp_theme_features['post-thumbnails'][0]) )
        $_wp_theme_features['post-thumbnails'][0][] = 'your-cpt';
}

Leave a Comment