How to show custom post template from single page?
We know that in WordPress the default post template file is single.php.
Now, I have one category name "members" and want members posts to show a
custom template, like content-members.php.
I can do that via custom post template plugins. but is there a way to make
that without plugins?
Maybe we can do that like this:
<?php
if ( is_category( 'members' ) ) {
get_template_part( 'content', 'members' );
} else {
get_template_part( 'content', 'common' );
}
?>
I tried this already, but it's not working and I think category is not
triggering here.
No comments:
Post a Comment