Return category name with & Ampersand doesnt work

I have a category named: This & That

However, for some strange reason my switch code doesn’t pick it up. When I output $firstcat it does return This & That which makes it even more cumbersome.

The code works fine for other categories not containing the ampersand &.

function posend_text_shortcode() {
$mycategory = get_the_category();
$firstcat = $mycategory[0]->name;
switch($firstcat){
case “This & That”:
include(get_stylesheet_directory() . ‘/inc/style/check.php’);
break;
default:
include(get_stylesheet_directory() . ‘/inc/style/default.php’);
break;
}
}

Read more here:: Return category name with & Ampersand doesnt work

Leave a Reply

Your email address will not be published. Required fields are marked *