I cannot use the themes “header” ad slot because I have a custom post type for sponsored articles I do not want adsense appearing on (and additionally slowing down the load time of the sponsored posts). My dev created a /s/ slug to represent the sponsored post type and we tried adding a conditional to the header ad slot to not load the adsense responsive code when /s/ is present in the url but while we were successful in hiding the ad (a big no no for google) the ad scripts still appear and slow down the load time so I’ve had to abandon using the header ad slot all together. If you have any other suggestions to prevent adsense header ad slot from loading ads/adsense scripts on a certain “sponsored” post type or urls that have /s/ in them please let me know – otherwise I have been forced to use the workaround:
I created a custom ad slot 1 with google responsive code on the homepage using VC which works, but I don’t have the same ability to do that on category pages. The theme panel > layout settings > categories section seems restrictive in how it can be customized. How would I add a “custom ad slot 1” ad to the top of every category page? Similarly, how can I define a post template to use “custom ad slot 1” as a header (almost all of my posts are set to default or from panel post templates)?
Thanks in advance for reading all that! Looking forward to your reply
-
This topic was modified 10 years by
schindyguy.
Hello schindyguy,
If you are talking about the ads on category page, the simplest way to add this on that pages are to use a shortcode for each category top post template used, like this: http://screencast.com/t/icImxD0wIoVc
<?php echo do_shortcode('[td_block_ad_box spot_id="custom_ad_1"]')?>
Also, if you need to remove ads from certain post/pages, please check the topic below and implement this on your custom post type. https://forum.tagdiv.com/topic/remove-ads-in-certain-postpage/ You should put the condition in ads.php using a custom post type function. For more function reference in WordPress, please check the WP Codex, here: https://codex.wordpress.org/Function_Reference
If you are not aware the steps to do this thing, please consider hiring a freelancer/developer to do this thing for you, because we cannot provide custom work for the moment, sorry!
Hope this helps and let us know how it goes!
Thank you for the message!
Thanks Catalin! The topic seems to use post or page ids to exclude the ads, what would the code be to exclude all posts for a specific custom post type named ‘sponsored’?
Hello,
You can use this function to achieve the result you want: https://codex.wordpress.org/Function_Reference/post_type_exists
Simply use the id you gave your post type in the function.
Thank you!
Bogdan, wasnt able to find a is_post_type(sponsored) function so if anyone else has this issue you can modify this conditional https://forum.tagdiv.com/topic/remove-ads-in-certain-postpage/ to look for a tag “sponsored” which worked like a charm
wp-content/themes/Newspaper/includes/shortcodes/td_block_ad_box.php
on line 27, I added added
if (has_tag(sponsored)) {
return;
}
Thanks again for the help!