1. Support
  2. Knowledge Base
  3. Tutorial
  4. How to place ads and banners in your WordPress theme

How to place ads and banners in your WordPress theme

We often receive requests about how to place advertisements (ads or banners) in WordPress themes to monetize a website. With this tutorial we would like to explain how you can place ads on your website very easily using a standard WordPress text widget and how you can make use of the Advertising options in our popular MH Magazine WordPress Theme to place ads automatically inside the post content or between the posts on archives.

Placing ads by using a WordPress text widget

The standard WordPress Text widget, Block widget and Custom HTML widgets are fantastic all-rounder which can be used to do all kind of great things. These three widgets almost have the same function. You can insert almost anything you want in a text widget, starting from normal text, up to images (using HTML) and shortcodes or any other HTML code you want.

Text Widget
Text Widget
Custom HTML Widget
Custom HTML Widget

The WordPress Text Widget and Custom HTML Widget are ones of the widget options that comes in the basic installation of WordPress and WordPress.com, no Plugin required. It adds an HTML container to your WordPress Theme's sidebar.

Block Widget
Block Widget

The new editor allows users to add blocks to their widget areas using the familiar block editor interface introduced in WordPress 5.0. This gives users powerful new ways to customize their sites using the rich library of core and third party blocks. Block Widget also comes in the basic installation since WordPress 5.0 launched.

Text widget, Block widget and custom HTML widgets are perfect for placing ads on your website. Placing ads on these three widgets is very simple, just insert your ad code (like e.g. Google AdSense or any other ad provider) into a text, block or custom HTML widget and place the widget in any of the available widget areas of your theme, e.g. in one of the many available widget locations of MH Magazine WordPress Theme. When you have placed the widget in a widget area, it will automatically display the content you have added.

What is an ad code and where to get it?

An ad code is a piece of HTML or JavaScript code which you will need to add to your website to properly display the ads. You can get these ad codes from any ad provider of your choice. An ad code of Google AdSense looks e.g. like this:

<script async src="//pagead2.googlesyndication.com/pagead/js/adsbygoogle.js"></script>
<!-- Example Ad 300x250 -->
<ins class="adsbygoogle"
     style="display:inline-block;width:300px;height:250px"
     data-ad-client="ca-pub-xxxx9321094xxxxx"
     data-ad-slot="xxxx0441xx"></ins>
<script>
(adsbygoogle = window.adsbygoogle || []).push({});
</script>

Just insert this kind of ad code into a text widget, place the widget in any widget area of your choice and it will display your ad. In this example it is a 300 x 250px AdSense banner ad. Of course this example code won’t work for you, so if you want to advertize with Google AdSense, just register a Google AdSense account, grab your own ad code and place it on your website.

How to place ads without an ad code

If you want to place ads on your website without a pre-defined ad code (e.g. if you got a direct booking from a client), you can display ads very easily by adding simple HTML into a text widget. Example of adding a linked image / banner with HTML:

<a href="URL of Advertiser" target="_blank"><img src="Path / Location of Banner Image" alt="Custom Text" /></a>

Placing ads using the Advertising options of MH Magazine

MH Magazine WordPress theme has included Advertising options to display ads in your post content or on archives very easily, without using a widget. You can find the Advertising options in your WordPress dashboard under Appearance => Customize => Theme Options => Advertising.

Advertising Options

When you navigate to the Advertising options section, you will find several forms where you can insert your ad codes or custom HTML code to display ads, just like you would do with a text widget. This is a very easy and comfortable way of adding ads to your content without the need to modify your content manually.

If you have inserted e.g. the ad code to display a content ad on posts, the theme will automatically display the ad in all your posts, like you can see in the below screenshot. In the Post Options below the post editor on single posts, you can also overwrite the global ad code with a custom ad code or disable the content ad for a specific post.

Content Ad on Posts

As you can see in the Advertising options section, there is also a form to insert an ad code to display ads on archives. If you have entered the ad code, it will show ads after every X posts on archives. You can modify the number of posts between every ad, default is 3, so by default there will be an ad displayed after every third post on archives, like in this example:

Advertisements Archives

How to display rotating ads / banners

Usually when you implement an advertisement, it will always be displayed on all posts and/or pages where you've embedded the ad code. If you want to display ads dynamically, to show different ads on posts, pages or archives which will automatically be replaced with every page impression for example, you could make use of dynamic content related ads like Google AdSense or make use of ad rotators. An example for a popular plugin to make use of rotating ad slots is Advanced Ads.

What to do if your ads are not showing up on your website?

In case your advertisements and banners are not showing up after you have added specific ad codes or HTML code to your WordPress website, please follow the checklist below:

  1. Make sure you have properly implemented the code
  2. Make sure your ad code is active (you can check that at your ad provider)
  3. Check if you are using any plugins that might cause conflicts
  4. Check if your site is possibly blacklisted or if your content meets the requirements

In addition, if you are using Google AdSense, it might take a while until your ads will appear on your website. The Google bot first has to crawl your website properly and it also might happen that AdSense ads won't be displayed on your website if your content is not appropriate based on the AdSense requirements which are defined by Google.

Please note that in general your WordPress theme doesn't prevent ads from showing up and your theme will only display the ad code which you've added to your site. That means there usually is no need to send support requests to your WordPress theme provider unless you have checked all the above mentioned scenarios. In case you've an issue with a particular ad network (e.g. Google AdSense) it's recommended to contact their support desk because your WordPress theme usually doesn't affect if your advertisements are showing up or not.

Was this article helpful?

Related Articles

Stay in touch with us!

Join our newsletter and we let you know about new theme releases,
as well as important updates and discounts.

Latest news from our blog: Core Web Vitals: What They are and How to Optimize Them for WordPress (21. January 2022)