I’ve created a custom post type as a plugin and released it into the repository. One of the core features involves using a featured image. I’ve added thumbnail
to $supports
in register_post_type()
, so the meta box shows up in the Administration Panel. I’m also hooking into after_setup_theme
and calling add_theme_support( 'post-thumbnails' )
, but I don’t think it’s taking affect.
The codex says you have to call it from the theme’s functions.php file, but if that’s true then it’ll only work if the user’s theme calls add_theme_support( 'post-thumbnails' )
(which would cover all post types. If the theme doesn’t call it, or only calls it on a specific type, then it won’t work.
Does anyone see a way around this problem?
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):This is what I ended up using, which is a modified version of Rarst’s answer