The filter hook you’re using is theme_<post type>_templates
, which means that the <post type>
part is dynamic and it’s the post type in which you want the custom template be added to the Template dropdown. So since the template is enabled for three post types, you would do so to add the template to the dropdown:
add_filter( 'theme_publication_templates', 'wp234234_theme_page_templates' ); // publication CPT
add_filter( 'theme_page_templates', 'wp234234_theme_page_templates' ); // regular Pages
add_filter( 'theme_post_templates', 'wp234234_theme_page_templates' ); // regular Posts
Or you can instead use the theme_templates
hook: ( Note: This hook runs before the ones above. )
add_filter( 'theme_templates', 'wpse_387479_theme_templates', 10, 4 );
function wpse_387479_theme_templates( $post_templates, $theme, $post, $post_type ) {
if ( in_array( $post_type, array( 'publication', 'page', 'post' ) ) ) {
$post_templates['/absolute/path/to/template-publication-special.php'] = 'Publication special';
}
return $post_templates;
}
PS: Just change the “publication” to the correct post type, if what I used is wrong?