Tuesday, 28 May 2013

render category template based on top level category wordpress

$curr_cat = get_category_parents($cat, false, '/' ,true);
$curr_cat = explode('/',$curr_cat);
$idObj = get_category_by_slug($curr_cat[0]);
// var_dump($idObj->slug);
if ($idObj->slug == "products") {
include(TEMPLATEPATH . "/_category-products.php");
die();
}
elseif ($idObj->slug == "projects") {
include(TEMPLATEPATH . "/_category-projects.php");
die();
}
else {
include(TEMPLATEPATH . "/_category-news.php");
die();
}
view raw gistfile1.php hosted with ❤ by GitHub
in category.php

Render difrent category templates based on top level category

No comments:

Post a Comment