(How To) Add “Ad Slots” To Your Site’s Pages

Ad Swapper ads are displayed on your site’s pages in Ad Slots.

NOTE! So if you DON’T have any Ad Slots on your pages, then NO Ad Swapper ads will appear on your site.

How Many Ad Slots Can / Must I Have ?

You can have as many Ad Slots – on each of your pages – as you want.  Including NONE.  But obviously, if you don’t have any Ad Slots anywhere on your site, then you’re expecting other sites to advertise you, without advertising those other sites yourself.  Which isn’t particularly fair.

NOTE! Ad Swapper DOESN’T currently check whether your site is displaying (Ad Swapper) ads or not.  Nor does it check how many ads your site is displaying (either per page – or in total).  But future versions ***may*** do these things.  For now however, as regards the number of Ad Swapper ads you display on your pages (and where), Ad Swapper relies on individual site owners to do the right thing.

Creating and Maintaining Ad Slots

You add, edit and delete Ad Slots by running the Maintain This Site’s Ad Slots option (from the Ad Swapper plugin’s Main Menu).

Adding and editing Ad Slots involves using a form that looks very long.  But in fact, there’s typically only 4 or 5 fields that you’ll ever need to set.

The remaining fields give you options that may occasionally be useful.  For example:-

  • The ability to disable an Ad Slot (so that it’s ads will no longer be displayed – but the Ad Slot remains defined, so that it can be re-enabled later).
  • The ability to customise the Ad Slot CSS (to cope with themes with crazy CSS, for example).

In most cases however, you’ll rarely need to use these fields.

The fields you normally set are:-

Eg; “header”, “footer”, “left-sidebar”, “right-sidebar”, “sidebar-or-column”, “banner”, “inline”, etc…
Eg; “Header”, “Footer”, “Left Sidebar”, “Right Sidebar”, “Sidebar/Column”, “Banner”, “Inline”, etc…
Select one of:-
  • Fixed-Height Banner
  • Sidebar
  • Fixed-Row-Height Grid

Click here for more info. and examples on the Ad Slot types.

Plus the Outer Width and possibly Outer Height fields, for each of the Ad Slot types.  Ie:-

Outer Width
For the selected Ad Slot type, set this field to the appropriate value.  For the non-selected Ad Slot types, set this field to a dummy value (eg; 999).
Outer Height
Only the Fixed-Height Banner Ad Slot type has an Outer Height field.  If the selected Ad Slot type is Fixed-Height Banner, then set this field to the appropriate value.  If the selected Ad Slot type is anything else, set this field to a dummy value (eg; 999).

Widget, PHP Function or Shortcode ?

Once you’ve created an Ad Slot, you can add it to your pages in any of three different ways:

  • Widget
    Using the Ad Swapper “Ad Displayer” widget.
  • PHP Function
    Using the adswapper_display_ad_slot_ads() PHP function (for use in WordPress templates, for example).
  • Shortcode
    Using the [adswapper-ad-slot…] shortcode (which allows you to insert ads into post or page content, for example).

Each of these three different methods is quick and easy to use.  Just use whichever works best (for you, and your site’s WordPress theme).

These three different Ad Slot insertion methods are described separately, below


Using the Ad Swapper Ad Displayer widget is probably the quickest and easiest way to add an Ad Slots to your pages (especially if you don’t have many programming skills).

To use the Ad Swapper Ad Displayer widget:-

  • Click AppearanceWidgets (in your wordPress back-end).
  • Drag the Ad Swapper Ad Displayer widget to the widget area you want to place the Ad Slot in.  Then;
  • Select the Ad Slot you want to appear in this widget (and click Save).

If you now go to the site’s front-end, you should now see Ad Swapper ads whereever you placed the widget.


  • If the ads don’t appear, or don’t look quite right, check/correct the widget and/or Ad Slot settings, as required.
  • You can place the Ad Swapper Ad Displayer in as many different widget areas as you like – and as many times as you want into a single widget area.  Just drag and drop to your heart’s content.

The only drawback with using Widgets, is that (although Widgets are a well-known part of WordPress), the vast majority of WordPress themes seem to have very limited Widget support.  A sidebar widget is all that most themes offer (and many don’t).  And as far as full-width header and/or footer Widgets are concerned, you’re generally out of luck.

So, if your theme provides no widget area where you want to place your Ad Swapper ads, then use the PHP Function method described below…

PHP Function

You can add Ad Slots to your pages by simply copy/pasting the following code into the appropriate theme template file(s):-

if ( function_exists( 'adswapper_display_ad_slot_ads' ) ) {
    echo adswapper_display_ad_slot_ads( '<ad-slot-name-here>' ) ;

Once you’ve copy/pasted the code, don’t forget to replace <ad-slot-name-here> with the name of the Ad Slot you want to display.  Eg; To display the “sidebar” Ad Slot:-

if ( function_exists( 'adswapper_display_ad_slot_ads' ) ) {
    echo adswapper_display_ad_slot_ads( 'sidebar' ) ;

Where the “ad-slot-name” to be entered comes from the Ad Slot’s “Name” field.

NOTE! Make sure you copy the whole three lines.  The middle line is the one that displays the ads.  And the first and last lines are there to stop PHP error messages appearing if you deactivate or delete the Ad Swapper plugin.  Omit these at your peril (unless you know what you’re doing).


You can insert Ad Slots into your posts and pages with the:-

[adswapper-ad-slot   name="<ad-slot-name-here>"]


Don’t forget to replace <ad-slot-name-here> with the name of the Ad Slot you want to display (from the Ad Slot’s “Name” field).

Fancy Stuff

If you have PHP, Javascript, CSS and WordPress programming skills, then you can often use the PHP Function method – to add Ad Slots to your site’s front and/or back-end pages, in more creative ways.

Here are some examples:-


EXAMPLE 1:  Fixed-Row Height Grid on WordPress Login Page.

Here we’ve created a 1 column x 3 row grid – and wrapped it in some HTML that displays it in a “fixed position” DIV – on the right of the WordPress Login Page.

In addition, we’ve placed a “hide these ads“/”show ads” link/button above the ads – and appended the necessary Javascript to make that link/button work.

You can test this here.


EXAMPLE 2:  Fixed-Row Height Grid on WordPress Dashboard Page.

The same as Example 1.  But this time on a custom WordPress Dashboard page.

You can test this here (if you Login with the demo username and password, first).