Why isn’t my if/elseif/else working correctly here?

is_category will not process the logic inside the argument list. This:

is_category('glorkian' || 'glork')

The condition is true on all category pages. What I think is happening is that PHP does parse that argument string, but is always going to be true. Try this:

var_dump('glorkian' || 'glork');

Meaning that what you are doing, essentially, is this:

is_category(true);

That is not a valid argument but the function seems to revert to default functionality– is this a category archive or not? Obviously, the answer is “yes” on any category archive.

Valid arguments are:

(mixed) (optional) Category ID, Category Title, Category Slug or Array
of IDs, names, and slugs.

http://codex.wordpress.org/Function_Reference/is_category#Parameters

So I believe that what you need is :

is_category(
  array(
    'glorkian',
    'glork'
  )
);

It is the same with has_category.

Leave a Comment