Hi,
Add this code:
$adcounter = 0;
and
$adcounter++;
if (is_category() or is_archive()) {
if ($adcounter == 2 or $adcounter == 4 or $adcounter == 6) {
echo do_shortcode('[td_ad_box spot_id="custom_ad_1"]');
}
}
in the loop.php file, like this: http://screencast.com/t/DsXKbb9C
This will add an ad after 2 post, 4 post and 6 posts on the category page and archive page also if you want you can change this simply by removing or by adding $adcounter == variable or changing it’s value as you want. Also notice that the code for these ad goes in the Ads > Custom Ad 1 > Your Custom Ad 1 in Theme Panel.
You will also need to add this custom CSS in Theme Panel > Custom CSS:
.category .td-a-rec-id-custom_ad_1{
margin-bottom: 30px !important;
}
.archive .td-a-rec-id-custom_ad_1{
margin-bottom: 30px !important;
}
You will get this result: http://screencast.com/t/nuHrZ7zhGY
Thanks
-
This reply was modified 12 years by
Lucian.
Is it possible to do this using a module? My homepage is using block 21 with a load more button, and I’d like to display ads between posts. Is this possible with your theme?
Thanks in advance!
Hello,
you can use ads the same way with a do_shortcode function. For a block 21 you need to edit module 16 and add this code to it:
<?php echo do_shortcode('[td_block_ad_box spot_id="custom_ad_1"]')?> like so: http://screencast.com/t/bmQjF5k6
This will insert an ad after every post in the module: http://screencast.com/t/xkKmZTqi9
It will need a bit of css to position it though if this is what you want.
Thank you!
Awesome thank you.
I’d like to change it up a little and only show an ad every 6 posts. Where can I set the adcounter to zero to have it loop properly for module 16?
Hello,
In order to do that, you will have to use the ad counter above and adapt it to a block 21 by altering this function: http://screencast.com/t/zsobDTbfbD
Unfortunately you will need to get some help if you cannot manage it as time does not allow us to offer any custom work.
Thank you!
Okay, I customized so the loop is working but the shortcode is not being executed?
See screenshot
https://gyazo.com/ffd7add35c45e07dd10ef26b95904e1b
Thanks in advance
Hello,
Unfortunately as i replied above, you will need some extra help as this task falls beyond what support can offer you. If you cannot manage to alter the function by yourself, you can hire a freelancer from sites like studio.envato.com as we cannot offer any custom work at the moment.
Thank you.
Hello,
As this topic is 1 yer old, the code will not work anymore as the shortcodes were changed. The method still applies though. You can use it like so: http://screencast.com/t/FoVvUOVY
I hope this helps.
Thank you!
Hi I was able to add the shortcode to the module 17 and the ad show up, unfortunately it show right after every post. see screeshot http://prntscr.com/bkpwpi
This is how my code look in module17
function render() {
ob_start();
?>
<div class="<?php echo $this->get_module_classes();?>">
<div class="meta-info-container">
<?php echo $this->get_title();?>
<div class="td-module-image">
<?php echo $this->get_image('td_696x385');?>
<div class="td-module-meta-holder">
<div class="td-left-meta">
<?php echo $this->get_author();?>
<?php echo $this->get_date();?>
</div>
<?php echo $this->get_comments();?>
</div>
<div class="td-category-corner">
<?php if (td_util::get_option('tds_category_module_17') == 'yes') { echo $this->get_category(); }?>
</div>
</div>
<div class="td-excerpt">
<?php echo $this->get_excerpt();?>
</div>
<div style="padding-top:30px; margin-bottom: -30px; ">
<?php echo do_shortcode('[td_block_ad_box spot_id="custom_ad_1"]')?>
</div>
<div class="td-read-more">
href;?>"><?php echo __td('Read more', TD_THEME_NAME);?><i class="td-icon-menu-right"></i>
</div>
</div>
</div>
<?php return ob_get_clean();
}
}
, is there anything else I need to add so the ad can be display on every 5 posts?
This is the last step before I can launch the site.
Please guide me to the right direction?
Thank you for your support.
Hello
Thanks, I success to have custom ads on default loop, archive, tag and category after 3 posts. this will be great if we can place custom ads on block for various customization in tagdiv composer.
I do some experiment to place custom ads on block 18. I put this code:
//insert adsense
$adcounter++;
if ($adcounter == 2 or $adcounter == 4 or $adcounter == 6){
$buffy .= do_shortcode('[td_block_ad_box spot_id="custom_ad_2"]');
}
On this file http://www.screencast.com/t/pmWcAIXu the custom ads show up on the block 18 after 2, 4 and 6 from posts lists http://www.screencast.com/t/wsT6hLeT. Also see live result is perfect http://www.screencast.com/t/5Ta26Pjoy. But the code is still not perfect, it’s because I can’t access tagdiv composer anymore hahaha http://www.screencast.com/t/sNKNE1u1o
It would be better if someone volunteered to help me to make this code works on the block 18 file. If this code is working, we can put custom ads in another block file. 🙂
Hi,
Please increase the wp_memory_limit and the tagDiv Composer will work just fine.
https://www.screencast.com/t/HwsGvfpzK
https://forum.tagdiv.com/requirements-for-newspaper/
Thank you.
Hello calin
Before I add that code for block 18, the tagdiv composer is work just fine, when I add it, I can’t access tagdiv composer anymore http://www.screencast.com/t/sNKNE1u1o
When I remove that code from block 18 file, the tagdiv composer back to normal again.
I want to add this code http://www.screencast.com/t/pmWcAIXu without getting any error on tagdiv composer, I don’t know what’s wrong with that code, the result is perfect on block 18 http://www.screencast.com/t/5Ta26Pjoy, but tagdiv composer is cannot be using again.
I am using localhost before I made any change on my website to avoid any error.
Thank you for your response. 🙂
Hello. Please tell me how and where to place the Adsens advertising code, so that the ad unit is displayed in the category-headings on the site as here – https://null-24.com/category/wordpress-plugin? To advertising blocks were repeated through one. Please tell me how do I do the same? Screenshot – https://yadi.sk/i/4TNiX6oPoF_UWw
Hi @WebMasterhi,
What I mean is that on your example that page of category in order to have a line of category posts, one of ads, you can get a category Template from tagDiv Cloud Library
https://forum.tagdiv.com/tagdiv-cloud-library-plugin/
You can edit the category template with TD Composer
https://www.screencast.com/t/dGXQN21Ww4Qx
https://www.screencast.com/t/QebUiMHvKdb
Hope this will help you better.
Thanks.
Hi,
I attempted to add the a ads between posts using the tagdiv composer by adding a block and then ads and then another block however since both blocks are from same category, the posts are getting doubled over. How can I add the ads between posts on category page without having posts duplicated?
Thanks
