Is there a way to add support for a custom feature for a custom post type, after it has been created?
I know how to create a custom post type using register_post_type(), and how to use the supports parameter to specify what the CPT should support;
'supports' => array( 'title', 'editor', 'author', 'thumbnail', 'excerpt' ,'headway-seo')
But for the situations when the CPT is being registered by a plugin or theme, is there a way to ‘inject’ support elements (manipulate the support array) of the CPT after it has been registered, using a WP hook/filter?
Yes, there’s a function called
add_post_type_support
Hook into
init
— late, after the post types have been created — and add support.Adding support for excerpts to pages for instance:
An alternative approach is to hook into
register_post_type_args
and update thesupports
array.This is particularly useful if you have third-party plugins that hook into the CPT arguments to display content.