When you are using a Custom Post Type with its Custom Post Taxonomies, you could need to detect if a particular category is displayed in a post. So, I write a simple WordPress shortocode you can use to detect a particular category and then display the content of the post.

To achieve that, you can add the following code in your functions.php file:

Next, in your post content you can use:

The wp_cpt and wp_tax are the Custom Post Type slug id and Custom Post Taxonomy slug id. The category argument is the category slug.