Forums

Show Image/banner based on specific category? (3 posts)

  1. arcab4
    Member
    Posted 4 years ago #

    Hello!

    I had a question that I can't really figure it out. I want a specific banner to show up based on what category it's in.

    for example, if i was in a post that was part of a wordpress category, i would want a wordpress banner to show up.

    if i was in a post that was part of a ebay category, i would want an ebay banner to show up.

    i figured a way sorta using If/Else statements but with a few dozen categories, I think that might be a bit extensive. i'm assuming if there was a way to pass a variable somehow that might be easier..

    ie. ebay category cat=1 and then for the banner code it would be something like /images/banner1.jpg .

    hope that makes sense?

    Thanks!

  2. arcab4
    Member
    Posted 4 years ago #

    for example, i was using if/else statements to do it. but if i have dozens of categories..there is probably a more efficient way of doing it right?

    <?
    if(is_home() ){
    	echo ("<img src=images/home.jpg>");
    } elseif(in_category(10) ){
    	echo ("<img src=images/category10.jpg>");
    }else {
    	echo ("<img src=images/others.jpg>");
    }
    
    ?>
  3. moshu
    Member
    Posted 4 years ago #

    No, there isn't.

Topic Closed

This topic has been closed to new replies.

About this Topic