nice, this may sound like a weird question, is there any way to disable the ads if members are logged in?
Support Forum
You can wrap your ad code like this…
if ( ! is_user_logged_in() ) {
... your ad code here...
}
This is a core WordPress function that returns true or false so this will only run the ad code if the user is NOT logged in.
thanks yellow, I would still need the echo at the top and the comma semi-colon at the end though correct?
would it look like this?
echo ‘if ( ! is_user_logged_in() ) {<script async src=”//pagead2.googlesyndication.com/pagead/js/adsbygoogle.js”></script>
<!– Responsive –>
<ins class=”adsbygoogle”
style=”display:block”
data-ad-client=”xxxxxxxxxxxxx”
data-ad-slot=”xxxxxxxx”
data-ad-format=”auto”></ins>
<script>
(adsbygoogle = window.adsbygoogle || []).push({});
</script>’;}
No….
if (!is_user_logged_in()) {
echo '
<script async src="//pagead2.googlesyndication.com/pagead/js/adsbygoogle.js"></script>
<!– Responsive –>
<ins class="adsbygoogle"
style="display:block"
data-ad-client="ca-pub-xxxxxxxxxxxxxxxx"
data-ad-slot="xxxxxxxxx"
data-ad-format="auto"></ins>
<script>
(adsbygoogle = window.adsbygoogle || []).push({});
</script>
';
}
lets try this again, if I wanted to show it on every say 3rd post, would I do this?
if($spTopicView->currentPost==3){
if (!is_user_logged_in()) { echo ' <script async src="//pagead2.googlesyndication.com/pagead/js/adsbygoogle.js"></script> <!– Responsive –> <ins class="adsbygoogle" style="display:block" data-ad-client="ca-pub-xxxxxxxxxxxxxxxx" data-ad-slot="xxxxxxxxx" data-ad-format="auto"></ins> <script> (adsbygoogle = window.adsbygoogle || []).push({}); </script> '; }
}well, if you want it after every third post (what you asked for), that is not how one would do it.. but sounds like you have what you want? It would show it only after the third post…