One of our most popular feature requests is to be able to display ads managed in WordPress on another site. This could even be one site not set up with WordPress. The following tutorial explains how to set up such a basic ad server using our Advanced Ads plugin as a basis.

What would you want an ad server for?

I’d expect most users who found this article that they already know why they are looking for an ad server. Still, here are a few use cases.

  • manage the same code on one place (the ad server) only and use it on many other sites
  • manage your ads with Advanced Ads and place them on any site, not just those developed with WordPress
  • manage content on a site that is not yours while being able to change that content in Advanced Ads
  • use the ad server code as a fallback for an ad network that doesn’t have a 100% fill rate and keep control of what the fallback code delivers
  • send the ad code to your affiliate partners and keep control of impression and click tracking on your end

Setting up the ad server

For this to work, you would need to

You can get the Ad Server Lite add-on from github and install it like any other WordPress plugin.

Once enabled, it manipulates Advanced Ads in a few simple ways to allow ads to be displayed on external pages.

Displaying an ad on another site

When you have your first ad created and published, just get the ad URL from below the title on the ad edit page.

Ad URL option

There are two basic methods to load the ad into the frontend of your site.

load the ad with an iFrame

The most simple method to load the ad is using an iFrame.

The basic code is

Replace LINKTOAD with the URL from the ad and set width and height according to your ad’s size. With the example above, the full code might look like this

load the ad with JavaScript

You can also load the ad using JavaScript, though it is likely to lead to an Access-Control-Allow-Origin issue and not load the ad from an external site.

Replace LINKTOAD with the URL from your ad in the following example.

As you can see, the ad is loaded into the ad-box container. Feel free to adjust that position.

load the ad with PHP / cURL

You can also load the ad using cURL in PHP or other programming languages, which we cannot cover in this tutorial.

What else you might need to know

If the ad content is retrieved from yet another third-party URL, it might not be executed on the target page.

Display and Visitor Conditions set for the ad in Advanced Ads are not going to work and might even prevent the ad from loading on the external site.

Ad networks might not allow this practice or some implementation methods. E.g., AdSense is not allowed to be loaded in an iFrame.