How to block Google Ads in some posts

Posted in: Newspaper
Post count: 43

Hi,

I have some adult posts in my site and I must to block Google Ads only on these articles.

My site is about movies, so the block can’t be by category. I think the best way to do this is by tag. My big problem is the Header and Article Ad.

Do you know excerpts or custom CSS to do this?

Regards,
CyberGetro

Post count: 854

hi,
you need to take the id of the post outside of the loop, then in the areas where the ads are showed you need to test to see if the post id is the adult one. if yes then don’t shoe the ad. use if else for this.

the theme was not created like this, and is not easy to do this.

hope this help.

Thanks for you message.
Radu A.

Post count: 43

Hi, Radu.

I don’t have needs to remove the post from the loop. I just need to prevent Google Ads appears in the post.

Do you have any clue?

Thanks,
CyberGetro

Post count: 58

@cybergetro: You can use the Plugin ‘Simple Ads Manager’. With ‘SAM’ you can show or block Ads by page, post, category, author, tag, rotate ads etc. Plugin works fine with Newpaper Theme an with the Ads Panel there (add shortcode and it works).
BTW: I’m not the author of this plugin.

  • This reply was modified 12 years by ocbln.
Post count: 43

Hi, ocbin.

I installed and looks nice but I have no clue how to change the ADS on Header, since the code must be inserted in the Theme Panel.

Do you know how to proceed in this matter?

Thanks for your answer.

Post count: 854

hi,

try looking over the documentation : http://www.simplelib.com/?p=480

Thanks for you message.
Radu A.

Post count: 95

If I want to use if else to control ads without plugin
What should I do?
Where should I put the code

Post count: 3343

Hi,
Here is an implementation, take a look on the entire tread. https://forum.tagdiv.com/topic/function-to-hide-ads-and-function-to-show-author/#post-9187

Thanks!

Post count: 3343

Of manual add condition by post ID and this will work without any plugins.

Post count: 95

Thx,
I will try it later
If the code change to check tags eg. noads , then will not show ads, it will better as no plugin is needed 🙂

Post count: 43

Hi Marius,

I tried to install Advanced Custom Fields like you suggest in the post [https://forum.tagdiv.com/topic/function-to-hide-ads-and-function-to-show-author/#post-9187], but I believe the instructions are outdated.

I can’t see this image posted by you on Screencast:

Then add this code and !get_field(‘hide_ad’) like here: http://screencast.com/t/5FOgXORGMMpand

AND if i do this: http://screencast.com/t/5FOgXORGMMp

I get this message

Parse error: syntax error, unexpected T_LOGICAL_AND in /home/getro/www/getrao/wp-content/themes/Newspaper-v3/includes/modules/module_modifier/td_module_blog.php on line 41

I’m doing something wrong or the code change since Newspaper Theme Version 3.0?

Regards,
Cybergetro

Post count: 3343

Hi,
Is not outdated, the solution works great, please read carefully the entire tread.

You have an old version? older then 3? Because we have changed the code a lot.
Something is wrong in your code.

Post count: 43

Hi,

My version is the 3.0.

I istalled and configured Advanced Custom Fields and

I did this http://screencast.com/t/5FOgXORGMMp and this http://screencast.com/t/A7KWAo2hlNRf and even this http://screencast.com/t/xFyqF7MGDa (for child themes).

I got the same error message.

The line is different from your Screencast figure, the php line for content_inline has “and $tds_inline_ad_paragraph > 0” not showed in your picture [http://screencast.com/t/5FOgXORGMMp].

I tried to remove it, but I got the error message either.

Any clues?

Thanks for your support (and patience).

Post count: 3343

Hi,
In v 3.2 we have changed the file structure and code, should be from there. Can you update to latest version and try again the customization?

Thanks!

Post count: 43

Hi, Marius.

Works fine on v 3.6! Thank you so much. But you’ll need to teach me how to do this again:

How to insert a title before facebook comments, just like this image: http://i.imgur.com/HuZBs99.jpg

because you last code: $buffy .= ‘<h4 class=”block-title”><span>Your title here</span></h4>’; like here in http://screencast.com/t/XPbr03VKsMR

was outdate now.

Regards,
Cybergetro

Post count: 3343

Hi,
Add the code like here: http://screencast.com/t/hEeojGi4kqa

<h4 class="block-title"><span>Your title here</span></h4>

Post count: 43

Hi Marius,

I did this http://screencast.com/t/A7KWAo2hlNRf
and this http://screencast.com/t/xFyqF7MGDa

but i can only hide the Content Inline. The Advanced Field code didn’t work on TOP (I don’t have Bottom ADS).

Any clue(s)?

Post count: 3343

Hi,
I’m not sure what you have there, do you use TOP and INLINE ad and you want to hide them on some posts?

The solution not work for you? I’ve tested provided and works fine for me. Please make sure you do all the think exactly like above.

Or if you want you can create a custom filed for the top ad and try again. Should work.

Thanks!

Viewing 18 posts - 1 through 18 (of 18 total)
You must be logged in to reply to this topic.