How to hide banners in selected categories?

Posted in: Newsmag
Post count: 115

Is possible do this?
I am not talking the default wordpress widget

Example: Header Banner choice category to show or hide

Post count: 6535

Hi

The theme doesn’t have an option to chose if the header ad will be displayed or not in a specific category. To remove the header ad from a category page you can add a conditions in ads.php like here: http://screencast.com/t/LO8DMY1T2Y

<?php
    if (!is_category(array(id1, id2))){
        echo td_global_blocks::get_instance('td_block_ad_box')->render(array('spot_id' => 'header'));    
}
    // show the header ad spot
   ?>

Just add the ids for the category pages in which you don’t want to display the header ad. To get the category id follow this link: http://screencast.com/t/AYBYVkw5

Thanks!

  • This reply was modified 10 years by Andrei L..
Post count: 115

Thanks Andrei

Post count: 11

Hi, for me this doesn’t work.

My ads.php is this:

<div class=”td-header-rec-wrap”>
<?php

// show the header ad spot
echo td_global_blocks::get_instance(‘td_block_ad_box’)->render(array(‘spot_id’ => ‘header’)); ?>

</div>

Can you help me? Thank you

Post count: 6535

Hi

The above code is tested and works fine just make sure you add it as I’ve indicated above. Also make sure you add a correct category id, otherwise won’t work. The code can be tested in a very simple way to check how it works. Added like here in ads.php:

render(array('spot_id' => 'header'));
}
// show the header ad spot
?>

This code will remove the header ad for all category pages. If this works just add your a category name as parameter for is_category function and will remove the ad for a that category page.

I hope this helps.
Thanks!

Post count: 11

Hi Andrei,

Thank you so much!!! it works 🙂

Last question: if i want to block AdSense code also in other position (ex: article top ad, inline and bottom) where I have to put the code?

Thank you! Awesome support!

Post count: 6535

Hi

Please check this topic, I’ve offered a solution here: https://forum.tagdiv.com/topic/article-inline-ad-3/
Let me know how it goes.
Thanks!

Viewing 7 posts - 1 through 7 (of 7 total)
The forum ‘Newsmag’ is closed to new topics and replies.