WordPress Development Stack Exchange is a question and answer site for WordPress developers and administrators. Join them; it only takes a minute:

Sign up
Here's how it works:
  1. Anybody can ask a question
  2. Anybody can answer
  3. The best answers are voted up and rise to the top

I have a parent category with many sub-categories and I am trying to display the page differently when it is in that specific parent category.

But instead of writing the code like is_category('parent', 'sub-1', 'sub-2')...etc, is there an easy way to say if it is in the parent category it is true?

share|improve this question

I'm not sure I fully understood your question, but wrapping a function inside a new function will make it shorter. For example, do the following in your functions.php file:

function is_parent($slug){
       return true;
       return false;

And then simply use it like:

    // do something
share|improve this answer

Your Answer


By posting your answer, you agree to the privacy policy and terms of service.

Not the answer you're looking for? Browse other questions tagged or ask your own question.