Get custom text if in Category

in_category takes 2 parameters, the first being the categories to check, and the second being the post ID.

If we look at the official documentation on wordpress.org we can see these are the parameters that this function can accept:

in_category( int|string|int[]|string[] $category, int|object $post = null )

Taken from: https://developer.wordpress.org/reference/functions/in_category/


We can also see in the official documentation for that function an example of checking more than one category by using an array:

if ( in_category( [ 'Tropical Birds', 'small-mammals' ] ) {