display banner only if post belongs to specific category.. on single post basis
-
Hello, I need help in trying to make it so that per example “banner1 appears if and only if a post belongs to a specific category xxx, else show banner 2 if post belongs to specific category zzz, and so forth… problem is, that a post could be tagged to several categories, but if it belongs to either xxx or zzz, then it should show appropraite banner, even if it also belongs to anyother category. At the end, “if none of the specified categories appear, then show whatever other banners i want…”
I tried placing the tag (is_category(‘xx’), and it does show appropriate banners like with this code:
<?
if (is_category(‘100’)) { include(‘banenr1.php’); }
elseif (is_category(‘101’)) { include(‘banenr2.php’); }
else {
include(‘banenr3.php’);
include(‘banenr4.php’);
include(‘banenr5.php’);
}
?>Problem I am having is, this is based on a “category” basis, and it will only work if one searches per category, but if one clicks in one of the post of said category, then it loses the “category” hint and then all “other” banners show, instead of the one banner which did appear under the category view… since now one would be viewing a single post…
So, instead I created a single.php template page, and coded it a bit different to see if it could somehow “pickup” a single post’s category… but no luck, and therefore hopefully show correct banner.
Any help will be appreciated!
Thanks
- The topic ‘display banner only if post belongs to specific category.. on single post basis’ is closed to new replies.