• Hi, I want to display a banner image for different categories and this thing does not work. A error “Parse error: syntax error, unexpected ‘}’ in…”

    <?php if (is_category('3') ):
     // we're in the Plants category, so show a plant ?>
     <img src='/images/plant.png' alt='a plant' />
    <?php } elseif (is_category('4') ):
     // we're in the Flowers category, so show a flower ?>
     <img src='/images/flower.png' alt='a pretty flower' />
    <?php endif; // end the if, no images for other other categories ?>

    Need help. Thanks

Viewing 1 replies (of 1 total)
  • Using an : with an if statement means you close it using something like endif, as opposed to a }. So your code should look like this:

    <?php if (is_category('3') ):
     // we're in the Plants category, so show a plant ?>
     <img src='/images/plant.png' alt='a plant' />
    <?php : elseif (is_category('4') ) :
     // we're in the Flowers category, so show a flower ?>
    <img src='/images/flower.png' alt='a pretty flower' />
    <?php endif; // end the if, no images for other other categories ?>

    You had the others right, but on line 4, you needed a :

Viewing 1 replies (of 1 total)
  • The topic ‘Display an Item for certain categories’ is closed to new replies.