• Hi, I have a few custom menu bar items. One for ‘News’, which shows a category-16.php template for posts categorised as ‘News’, and a regular category.php file for all other category post pages.

    When the menu bar button ‘News’ is clicked, I use a ‘is_category(‘News’) function to set the css class=”selected”.

    However the second nav button needs a formula to add class=”selected” for is_category() to be true, but not if is_category(‘News’) is also true.

    How can I do this? Is this a simple if… else function?

    I have tried this but it brings about an error 500 error message. Is my formatting the issue?

    <?php if (is_category('News')) : else : if (is_page('Cakes') || is_category('')) { echo 'id="selected"' } endif; ?>

Viewing 1 replies (of 1 total)
  • Is my formatting the issue?

    Well, you’ve got 2 ‘if’ statements but only 1 ‘endif’.

    <?php if (is_category('News')) [ do A ]
    elseif (is_page('Cakes') || is_category()) [ do B ];
    ?>
Viewing 1 replies (of 1 total)
  • The topic ‘Using is_category() if category is not category x’ is closed to new replies.