Disable article top ad in certain category ID

Posted in: Newsmag
Post count: 35

I want to disable article top ad & article bottom ad at one category.

Is this possible ?

Thanks in advance for your kind support!

Post count: 35

//add the top ad
if (td_util::is_ad_spot_enabled(‘content_top’) and is_single()) {
$content = td_global_blocks::get_instance(‘td_block_ad_box’)->render(array(‘spot_id’ => ‘content_top’)) . $content;
}

//add bottom ad
if (td_util::is_ad_spot_enabled(‘content_bottom’) and is_single()) {
$content = $content . td_global_blocks::get_instance(‘td_block_ad_box’)->render(array(‘spot_id’ => ‘content_bottom’));
}

here i want to EXCLUDE one CATEGORY ID

Post count: 35

Any ideas ?

Post count: 1291

Hi,

You have to take the categories from the current post, use get_the_category( $this->post->ID ); , it returns an array. Create a variable, ex. named $excluded_cat , and set it to 0 (zero), use foreach to compare each element with the category you want to eclude, if it’s present set the $excluded_cat to 1.
Add a condition like – if (($excluded_cat == 0) and is_single()) { ..

You can see something similar here – http://screencast.com/t/ClZqqdqaJ1

If you don’t know how to build this i advise that you look for a professional developer to build it for you.

Thank you, Emil G.

  • This reply was modified 11 years by Emil G.
Viewing 4 posts - 1 through 4 (of 4 total)
The forum ‘Newsmag’ is closed to new topics and replies.