Categories
Web Development

WordPress: Multiple layouts in single.php, depending on post category

This snippet allows you to server different views depending on post category.

if($wp_query->query['category_name'] == 'categoryname1') {
	include_once( 'template1.php' );
} else if($wp_query->query['category_name'] == 'categoryname2') {
	include_once( 'template2.php' );
} else {
	include_once( 'template3.php' );
}

 

Leave a Reply