WordPress.org

Ready to get started?Download WordPress

Forums

[resolved] show different content on category and home (3 posts)

  1. visiblemedia
    Member
    Posted 5 years ago #

    I found this code:

    <?php if (is_category('baseball')) { ?>
    baseball
    <?php } elseif (is_category('football')) { ?>
    football
    <?php } elseif (is_category('hockey')) { ?>
    hockey
    <?php } elseif (is_category('basketball')) { ?>
    basketball
    <?php } else { ?>
    every other category
    <?php } ?>

    which works GREAT! except I want to also have a piece of code (a banner ad actualy) show only on the home page, as well as the ones targeted to specific categorys, and the one not targeted to any category. Does anyone know how to do this?

    I tried this:

    <?php if (is_home()) { ?>
    home
    <?php elseif (is_category('baseball')) { ?>
    baseball
    <?php } elseif (is_category('football')) { ?>
    football
    <?php } elseif (is_category('hockey')) { ?>
    hockey
    <?php } elseif (is_category('basketball')) { ?>
    basketball
    <?php } else { ?>
    every other category
    <?php } ?>

    Which seems like it should work, but it doesnt... what did I do wrong?

  2. moshu
    Member
    Posted 5 years ago #

    <?php if (is_home()) { ?>
    home
    <?php elseif (is_category('baseball')) { ?>

    You didn't close the opened {

    ==> ?php } elseif (is_etc

  3. visiblemedia
    Member
    Posted 5 years ago #

    AWESOME! that worked thanks.

Topic Closed

This topic has been closed to new replies.

About this Topic