Creating a conditional sidebar for single.php based on the category name or number
Description
This code allows you to have multiple conditional sidebars in the single.php page but only show them based on the category name or number that is indicated
This code allows you to have multiple conditional sidebars in the single.php page but only show them based on the category name or number that is indicated
HTML Source Code
<?php
if (in_category('9')) {
get_sidebar('queenssizechart2');
} elseif (in_category('4')) {
get_sidebar('queenssizechart');
} else {
get_sidebar();
}
?>
<?php
if (in_category('queens')) {
get_sidebar('queenssizechart2');
} elseif (in_category('kings')) {
get_sidebar('kingssizechart');
} else {
get_sidebar();
}
?>