wordpress if is in categroy 1

wordpress if is in categroy

// Find out in WordPress if a single/page is in a chosen category
if (in_category('fruit')) {
    echo "This single/page is in category 'fruit'.";
}

Here is what the above code is Doing:
1. We’re using the in_category() function to check if the current single/page is in a category.
2. We’re passing the category name as a parameter to the function.
3. If the single/page is in the category, we’re displaying a message.

Similar Posts