Skip to content

Instantly share code, notes, and snippets.

@chillbits-legacy
Created November 10, 2016 05:18
Show Gist options
  • Save chillbits-legacy/d205f1cfd54cf7643beb396e9a729990 to your computer and use it in GitHub Desktop.
Save chillbits-legacy/d205f1cfd54cf7643beb396e9a729990 to your computer and use it in GitHub Desktop.
Display different sidebar based on category of single post
<?php
if(is_single()) {
$categories = new WPSEO_Primary_Term('category', get_the_ID());
$category_id = $categories->get_primary_term();
$category = &get_category($category_id);
switch($category->slug) {
case 'blog':
continue;
case 'thien-nguyen':
smk_sidebar('sr461_252etf');
break;
case 'dau-tu-tai-chinh':
smk_sidebar('sr461_138wel');
break;
default:
dynamic_sidebar('sidebar-right');
break;
}
}
?>
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment