One easy way is to use has_category
function.
E.g. in your header you can use
if ( has_category('pirtek') ) {
$header="/path/to/pirtek/header"
} else {
$header="/path/to/standard/header"
}
If the post has the ‘kirtek’ category, then the condition inside if
is true
, no matter what other categories the post belongs to.
This kind of if
statement can be used everywhere you need, however, the snippet above works well in singular templates and inside the loop. If you want to use that conditional outside the loop, you need to pass the post object as second argument of has_category
.
$postid = 10;
if ( has_category( get_post($postid) ) ) {
// do something
}