Q&A
Mr. Pickles the AdPlugg Pug

Is there a way in Wordpress (without using the WP plugin) to check to see if any ads are available for a zone?

+1
0
-1

Is there a way in Wordpress (not using the WP plugin) to check to see if any ads are available for a zone? I only want to present the zone if there are ads available for display there.

 

Thank you!



Any code to add to my php function would be very helpful.

Answers

+1
0
-1

This is very helpful. Thank you!

+1
0
-1

If possible, I'd recommend doing this using JavaScript in the user's browser rather than using PHP on the server. If you are checking for ads server side, it is going to effect your ability to cache your pages. It is also going to keep you from being able to make decisions in real time on a per user basis.

If you are amenable to using JavaScript, we have an example of how to do it using a JavaScript event listener here:

https://jsfiddle.net/adplugg/k57a6u3b/

Basically this will set an event listener when AdPlugg fills the ad tag. If no AdPlugg ads are found, you can set a function to do something else. Please let us know if you need help implementing this.

If you'd perefer to do it server side using PHP, please contact us for instructions.