Welcome to the Question2Answer Q&A. There's also a demo if you just want to try it out.

How to make Adsene ads do not appear on selected pages

+3 votes
asked Jan 12, 2016 in Q2A Core by Aras Ahmed

I received an email from Adsense said that I have to do not allow to ads be appeared on the page which contain questions and answers about some things. I see that pages is more and receive good traffic so I do not like to remove its Is there and method or code to block the ads from selected pages ?

Thank you.
commented Jan 12, 2016 by truthonlytruth
I want to know this too, but you are asking about a keyword check before you display AdSense code like this (it is just an example not a working code)

if ($words ! = $AdsenseWords)
      echo "Adsese Code";
     echo "";

Something like this... and you have to come up an array (list) of AdSense unacceptable words list also you have to create an array of words from every question and check those words over AdSense array and display the code or NOT

1 Answer

+2 votes
answered Jan 13, 2016 by Scott
edited Jan 13, 2016 by Scott

I can't think of a way to do this out of the box in Q2A, but it should be possible using an advanced theme.

You didn't say how you were displaying Adsense currently (the built-in plugin?) but you could change it to the theme instead. For example at the top of the main() function.

Once you have done that, you can then add an if clause to check what page you're on. Something along the lines of

public function main()
    if (strpos('word', $this->content['title']) === false) {
        $this->output_raw('output adsense code here');



commented Jan 25, 2016 by Aras Ahmed
I am using widget Anywhere to display the ads