I'm trying to register a metabox for some custom post types. Currently, I'm using the add_meta_box function with the screen parameter set to the post type slug:
$post_types = ['post', 'page', 'cms_pim_profile', 'cms_resource_hub', 'cms_stories', 'cms_opportunities', 'cms_events'];
foreach ( $post_types as $post_type )
{
add_meta_box(
'cms2019-sticky-until-' . $post_type,
'Sticky',
'cms2019_sticky_until',
$post_type,
'side',
'high'
);
}
The problem is that the metabox simply does not appear for posts - the custom post types and the default 'post'. It does, however, correctly appear for pages, so I know the display/save functions are working correctly.
Is there something else I need to do for posts?
You need to add a action-hook.
For the meta-box it´s called:
add_action('add_meta_boxes', 'your_function_name');
function your_function_name() {
add_meta_box(...);
}