WordPress.org

Ready to get started?Download WordPress

Forums

Show banners/ads based on Category? (6 posts)

  1. vgsmike
    Member
    Posted 5 years ago #

    Is there a plugin that will allow someone to serve specific banners/ads/iframes based on the category they are viewing?

    i.e. For an animal blog, a dog banner shown in the dog category, cat banners in the cat category, etc. Thanks.

  2. Josh Leuze
    Member
    Posted 5 years ago #

    I don't think that there is a plugin to do this. But you could do it by adding conditions to you theme. PHP that says, if it is this category, do X, else if it is this category, do Y.

    Look up conditional tags or if statements in the codex, that should get you going in the right direction.

  3. vgsmike
    Member
    Posted 5 years ago #

    Thanks. I wish I were much of a coder, but I'm not. LOL.

  4. Josh Leuze
    Member
    Posted 5 years ago #

    This page in the codex about conditional tags can give you more than enough information about how to do this.

    But for what you need, the code could be pretty simple:

    <?php if ( is_category( 'cat') ): ?>
    <!-- Insert code for cat ad here -->
    Test Cat
    
    <?php elseif ( is_category( 'dog') ): ?>
    <!-- Insert code for cat ad here -->
    Test Dog
    
    <?php else: ?>
    <!-- Insert code for generic ad here -->
    Test Generic
    
    <?php endif; ?>

    Stick that in your footer or sidebar and try the different categories, your results should vary depending on which category you are in!

  5. vgsmike
    Member
    Posted 5 years ago #

    Wow, this seems to be working. I'm definitely on the way now. Thanks a lot.

  6. Josh Leuze
    Member
    Posted 5 years ago #

    No problem vgsmike, best of luck!

Topic Closed

This topic has been closed to new replies.

About this Topic