I know we could use single-custom-post.php
But i have multiple custom post type
like
america
nepal
norway
i can do single-america.php
, single-nepal.ph
p , single-norway
. But they almost have same code basically violating DRY
. I am currently registering such post from plugins . How to show the template for them inside plugin with name lets say single-country.php
?
I think we can use template_include
filter? but i still don't have idea to do it?
tried like this
add_filter( 'template_include', function ( $template ) {
$cpt=["america","nepal","norway"]
if ( //how to check condition if it is custom post type single ) {
return ADVANCED_NOTES_DIR . 'country-single.php';
}
return $template ;
}) ;
So can we use same template for multiple custom post type single?
thank you :)