Add custom code to list.php depending on category?
-
Hi there,
I am trying to add banner adds to the top and bottom of ad category listings dependent on what category is being viewed.
So for example if viewing the “Motorbikes” category I would show banners related to motorbikes at the top and bottom of category.
I’ve copied list.php to my child theme and tried various things but nothing is working?
I’ve added this to the top of the file:
<?php $advert_category = get_the_terms( get_the_ID(), 'advert_category' ) ?>
and then tried:
<?php if ($advert_category = 'Motorcycles') { mycodehere } ?>
and
<?php if( $advert_category[0]->name == "Motorcycles") { my code here } ?>
at various places in list.php where I want the code to work and nothing happens?
Thanks in advance…
The page I need help with: [log in to see the link]
- The topic ‘Add custom code to list.php depending on category?’ is closed to new replies.