If you are sure your custom post type is using the default WordPress categories then you will be able to use has_category
if( has_category( 'web-designing' ) ) {
// do something
}
Categories are one of the built-in taxonomies in WordPress, but they only appear in posts by default. Your Custom Post Type might have it's own taxonomy in which case the function you are looking for is has_term
as per the reference you can use this to check if the current post has any of given terms within a custom taxonom. e.g. the product_cat
taxonomy in the below example.
if( has_term( 'web-designing', 'product_cat' ) ) {
// do something
}
与恶龙缠斗过久,自身亦成为恶龙;凝视深渊过久,深渊将回以凝视…