Skip to content

Instantly share code, notes, and snippets.

@spencejs
Created March 22, 2013 03:44
Show Gist options
  • Select an option

  • Save spencejs/5218806 to your computer and use it in GitHub Desktop.

Select an option

Save spencejs/5218806 to your computer and use it in GitHub Desktop.
Add Single Post Templating By Category In Wordpress
//Add Single Post Templating By Category
add_filter('single_template', create_function('$t', 'foreach( (array) get_the_category() as $cat ) { if ( file_exists(TEMPLATEPATH . "/single-{$cat->term_id}.php") ) return TEMPLATEPATH . "/single-{$cat->term_id}.php"; } return $t;' ));
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment