different Header ad´s by categorys

Posted in: Newspaper
Post count: 10

I have one small problem:

On my site: http://www.rheinhessen-news.de I have ONE advertisment at the top (mydoor) – so NOW , i want different ads, for each category another one.
I don´t know how to solve it.

Post count: 6535

HI

To achieve the desired result you will need some customizations in theme’s core files. Please check this link for more details in this regard: https://forum.tagdiv.com/topic/different-header-ads-according-to-category/

Thanks!

Post count: 10

Unfortunatly it doesn´t work.
I have 2 pics:
The main pic (have to displayed EVERYWHERE, “INSTEAD” of posts in the category/regional/mainz-bingen area).
I have the NEWSPAPER theme – found the ads.php, I added the code, so the ads.php looks now:

<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’)); ?>
<?php
if (in_category(array(‘mainz-bingen’))){
echo do_shortcode(‘[td_block_ad_box spot_id="custom_ad_3"]‘);
}
else{
locate_template(‘parts/header/ads.php’, true);
}
?>

</div>

I made an CUSTOM AD 3 also on the THEME PANEL -> ADS – there is the inculded code:

<div class=”td-all-devices”></div>

The HEADER AD looks as follow:

<div class=”td-all-devices”></div>

So – what did I wrong?

Post count: 6535

Hi

You’re using in_category() function in your condition which is not correct. To check if a specific category page is displayed you need to use is_category(), please check my first reply from indicated thread.
The condition should look like this:

if (is_category('cat-name'){
echo do_shortcode(‘[td_block_ad_box spot_id=”custom_ad_3″]’);
}
else{
echo td_global_blocks::get_instance(‘td_block_ad_box’)->render(array(‘spot_id’ => ‘header’)); ?>
}

Thanks!

Post count: 10

Unfortunatly even NO WORK.

My ads.php looks now:

<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’));
if (is_category(‘mainz-mingen’))
{
echo do_shortcode(‘[td_block_ad_box spot_id="custom_ad_3"]‘);
}
else
{
echo td_global_blocks::get_instance(‘td_block_ad_box’)->render(array(‘spot_id’ => ‘header’));
}
?>
</div>

So – do I have to take any other changes in any other files?

So as I understood I have to use if in_category – because I wan to show this other graphic (placed in custom ad 3) on EVERY POST, which is made IN THIS CATEGORY.

I did´nt know that this could be such a problem, I thought I can change this in the panel by choosing, cos I´m not a really *.php genius 🙂

Post count: 6535

HI

If you want to display custom ad-spots on a specific category page the code should be like here: http://screencast.com/t/M1166PUAXraNhttp://screencast.com/t/RWZpjGgcMhttp://pastebin.com/iK4pcacv
However if you want to display custom ads for posts from a specific category your code will be like this: http://screencast.com/t/hjSNwLiM88tvhttp://screencast.com/t/JYqxYXIyEIryhttp://pastebin.com/CRCVk025

Hope this helps!
Thanks!

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