How to place ads and banners in your WordPress theme

Learn how to place ads on your website very easily

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 is a fantastic all-rounder which can be used to do all kind of great things. 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.

WordPress Text Widget

Text widgets are also perfect for placing ads on your website. Placing ads using a text widget is very simple, just insert your ad code (like e.g. Google AdSense or any other ad provider) into a text 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 text 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 AdRotate.

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.

Share this with your friends

25 Comments

  1. Hi, I would like to ask where can I get the “Default WordPress Text widget with advertisement” which you use in the MH Magazine theme. I do not have that widget in my WP dashboard. Do I need to download a plugin? Thank you for your help. Regards, Iveta

      • In the “Available Widgets” section there is one widget called “Custom HTML”, in the top group, and another widget called “Text” appearing after the MH group. It would be good to clarify the instructions regarding this.

        • Hi James, both of these widgets are WordPress core widgets. The Text widget has been updated with a visual editor in WordPress 4.8. This change in WordPress was causing issues with code and beginner users were struggling to add code into the new Text widget. That’s why WordPress core developers have introduced the new Custom HTML widget. That means you can now use the Custom HTML widget for adding your ad codes instead of the Text widget.

  2. Hi, this is good and informative. Would you happen to know if the above is applicable with most WordPress themes, free or paid, particularly the default WordPress 2016 theme? Thanks.

    • Hi Howard, the Text widget is a WordPress core widget, so that widget should be available with any WordPress theme. But when it comes to placing advertisements, then it really depends on how your theme has implemented widget areas / sidebars and if these are suitable for advertisements. The other advertising options that are covered in this article are not available out of the box, these are available in our popular MH Magazine WordPress theme.

  3. Hi, is there any way of putting more than one ad in the ‘Ad Code For Content Ad On Posts’? I find if I put the code for two ads in there they go side-by-side and it doesn’t look right. The CTR for the ad within the content is much higher than my other ads 🙂

    • Hi Robert, thanks – we’re very happy to read that you’re seeing good results and click rates for the content ad on posts. Usually you’re supposed to display one ad there (recommended), but in theory you can add as many ads as you like. However, in that case you need to ensure with HTML/CSS that the ads are being displayed on top of each other and not side-by-side.

      In case you’ve purchased the theme, own a valid license for updates and support and if you need additional assistance, you can send a support request through your MH Themes account and our support staff will be more than happy to assist.

  4. I know this is off-topic but I’m looking into starting my own blog to make money online with ads. I was wondering what is needed to get my own blog started with WordPress? I assume having a blog like yours would be a lot of work? I’m not very tech-savvy so I’m not 100% sure. Any suggestions or advice would be greatly appreciated. Thanks.

    • Hi Blake, starting a blog isn’t hard at all, especially not if you want to use WordPress. We have a pretty extensive article about that: How to start a blog. If you want to make money online with advertisements, you need a WordPress theme that offers many possibilities to display ads. For that purpose you could have a look at our popular MH Magazine theme.

  5. Hi, after the WordPress 4.8 update ads in Text widgets wrap in <p>-tags. Updates to ad codes in the header automatically convert to media sources wrapping AdSense code inside paragraphs. Any idea how to bypass it?

    • Hi Janet, the Text widget has been fully recoded in WordPress 4.8. It now offers an editor to easily add formatting and links. It’s the same WordPress editor like when editing posts or pages.

      That means when you want to add code into a WordPress Text widget, you now need to switch to Text-mode in the Text widget. If you add code (Google AdSense or else) while you are in Visual-mode, then WordPress will strip the code for security reasons.

        • Hi David, since WordPress 4.8 the content in Text widgets goes through the same content filters like regular content in the WordPress editior. That means WordPress automatically adds <p>-tags or other formatting wherever it seems appropriate.

          While this is great for regular content, it certainly can cause issues with ads in some scenarios. When you put ad code into Text widgets, always ensure to use the Text-mode (otherwise the code usually will get stripped by WordPress) and also make sure that the code doesn’t include line breaks or paragraphs as this may lead to unexpected behavior.

  6. I find the WordPress 4.8 Text widget really problematic, but thanks to Enhanced Text Widget it works really well.

  7. When I copy the advertisement code from Google AdSense (using a Mac cmd-c) and paste it in Text mode into the widget on the MH Magazine theme it puts in the line breaks. Do you know how to remove these line breaks? Thanks.

    • Hi John, as mentioned above, the Text widget has been recoded in WordPress 4.8 and now the content goes through the same content filters like regular post content. That means <p>-tags are automatically inserted by WordPress when using the new Text widget.

      To prevent issues with that, please ensure that you’re using Text-mode (not Visual) and make sure that there are no line breaks or other stuff in the code that could end up as HTML markup or formatting. As an alternative you could use this widget to place ads: Enhanced Text Widget.

      As far as we know, the issue / bug with the Text widget will be fixed in WordPress 4.8.1 which will be released in August, but we can’t say for sure as we’re not involved in the WordPress development process. It also has been announced that WordPress 4.8.1 will include a Custom HTML widget which then can be used for ad code instead of the Text widget.

    • Hi Raghavan, you could manually place your ads at the preferred position into your post content through the WordPress editor. If you want to place ads in all your posts, you could automatically inject ads via suitable plugins for advertisements.

      As an alternative you could have a look at our popular MH Magazine theme which includes additional options to insert ads. For example there is an option to include a content ad after the first paragraph in posts which usually converts very well: Advertising options.

  8. Hi, I bought your MH Magazine theme yesterday and I’m just adjusting everything to fit my needs. Is it possible to have a background color in some of the posts? That would be nice to be able to meet the laws of internet marketing in Sweden that stipulate that a post that is paid for is an ad and that this shall be obvious for the readers.

  9. I’ve put code / advertisements with widgets into the widget areas Posts 1 and Posts 2 but the banners do not show. It just shows the code of my ads. What is wrong?

    • Hey, this is hard to answer without knowing the specifics, but if you see the code instead of the banners, then it’s very likely that you’ve used the Visual mode of a Text widget instead of Text mode (which is for code). As an alternative you could use the Custom HTML widget.

      Please also keep in mind that your WordPress theme just outputs your code as it is and doesn’t affect your ads in any other way. If ads are not displaying as expected, this can have several reasons (especially if you’re using Google AdSense). Here you can find more information: Common reasons why Google AdSense ads are not displaying.

Leave a Reply to Raghavan Cancel reply

Your email address will not be published.


*