WordPress.org

Forums

is_category conditionals (4 posts)

  1. CSSgirl
    Member
    Posted 8 years ago #

    I wanted to add a specific condition to my archive template that causes a different headline to display for a certain category. So I thought it would be easy enough to add an additional elseif condition to the archive template with all the others, but I keep getting a php error about an unexpected T_ELSE.

    So this is the code I was using:

    <?php /* If this is a category archive */ if (is_category(5)) { ?>
    <h2 class="pagetitle">Archive for the '<?php echo single_cat_title(); ?>' Category</h2>
    <?php /* If this is a category archive */ elseif (is_category()) { ?>
    <h2 class="pagetitle"><?php echo single_cat_title(); ?></h2>

    I've tries using just else, and that doesn't help either. Basically for Category 5 (and it's children if possible) I want to have that different category title to display.

    Thanks!

  2. Doodlebee
    Member
    Posted 8 years ago #

    You'r missing the closing "}", right before your "elseif".

    You are also, by the way, missing the closing "}" at the end, too.

    If you open something up, you gotta make sure you close it :)

  3. CSSgirl
    Member
    Posted 8 years ago #

    No sorry, that isn't the whole code. That is just the top part of the achives code. I'm using the standard code for the archives page, I just added in the conditional for category 5. I just copied the other elseif code on the page (for day, month, normal category, etc)

  4. Kafkaesqui

    Posted 8 years ago #

    doodlebee is correct. Try changing:

    <?php /* If this is a category archive */ elseif (is_category()) { ?>

    to:

    <?php /* If this is a category archive */ } elseif (is_category()) { ?>

    Note the closing } before elseif, which (properly) closes the previous if statement.

Topic Closed

This topic has been closed to new replies.

About this Topic