[ad_1]
I’m looking for a way to automatically apply a post-type-template to all the posts in a specific category, but I can’t find a workaround.
the closest I found is the category-slug.php [https://codex.wordpress.org/Category\_Templates]) …but I’m using the new [twenty-twenty-three]) theme and it seems to not use those files 🙁
any ideas?
[ad_2]
Category-slug is for the archive page of the category, not the individual posts within that category.
Interested to see what others recommend here. My gut reaction is to use conditionals in your single-post-type template to adjust the template when the post uses your category.
<?php if(in_category(‘special’)) { ?>
Your special template here
<?php } else { ?>
Default template here
<?php } ?>
Or if you really want separate files for each template, you could add something like this to your single template:
<?php $post = $wp_query->post;
if ( in_category( ‘special’ ) ) {
include( TEMPLATEPATH.’/single-special-cat.php’ );
} else {
include( TEMPLATEPATH.’/single-generic.php’ );
} ?>