Monetization

How to Insert Ads into Specific WordPress Posts

sovrnmarketing // April 4, 2016

How to Add Specific Ad Tags in WordPress sovrn.com

Our publishers often want to insert ads into specific WordPress posts rather than have ads show up on every post. Good news – it’s easy to do that!

There are two ways to insert ads into specific WordPress posts – you can either use a plugin or hard-code the ads manually.

How to insert ads into specific WordPress posts using a plugin

  1. Install and activate a plugin called Insert Post Ads. Upon activation, the plugin will add a new menu item called Post Adverts.
  2.  Click on Post Adverts » Add New. On the next screen, name the ad, enter the ad code itself, and select the paragraph where you want to display the ad code after. Once done, just click publish.

4. Next go to Post Adverts » Settings to select which post types you want to show the ads on (e.g. posts, pages, and custom post types).

How to insert ads into specific WordPress posts via hard-coding

If you don’t want to use a plugin, then follow the directions below.

  1. Open you theme’s functions.php or a site-specific plugin file and paste the following code:

2. To add the ad code, edit the “$ad_code value” where it says “Ad code goes here” on line 9

3. Once you do that, you are done. To change the paragraph number, just change the number 2 to another paragraph number on line 12

Want to learn more?

Share this article