Skip to content

Instantly share code, notes, and snippets.

Embed
What would you like to do?
Wordpress Single PHP theme based on category
<?php
/*
Template Name: Single News
*/
?>
<?php
// Switching if projects or if news
$proj='projects';
$catid=-1;
foreach(get_categories() as $category)
{
if($category->name==$proj or $category->slug==$proj)
{
$catid = $category->cat_ID;
break;
}
}
if (in_category($catid) && $catid!=-1)
{
include (TEMPLATEPATH . '/single-projects.php');
}
else
{
include (TEMPLATEPATH . '/single-news.php');
}
?>
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment