Skip to content

Instantly share code, notes, and snippets.

@infoscigeek
Last active May 11, 2017 04:52
Show Gist options
  • Save infoscigeek/e9ed9b4fc1da428049e6da058fdae34f to your computer and use it in GitHub Desktop.
Save infoscigeek/e9ed9b4fc1da428049e6da058fdae34f to your computer and use it in GitHub Desktop.
Category dependent post templates.
<?php
//by https://stanhub.com/about-stan-kostadinov/
//works as expected
function get_custom_cat_template($single_template) {
global $post;
if ( in_category( 'category-name' )) {
$single_template = dirname( __FILE__ ) . '/single-template.php';
}
return $single_template;
}
add_filter( "single_template", "get_custom_cat_template" ) ;
?>
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment