• 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!

Viewing 3 replies - 1 through 3 (of 3 total)
  • 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 ??

    Thread Starter Lindsey

    (@lalindsey)

    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)

    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.

Viewing 3 replies - 1 through 3 (of 3 total)
  • The topic ‘is_category conditionals’ is closed to new replies.