The Post Content placement allows you to automatically inject ads into the content of your posts and pages based on paragraphs, headlines, images or any other element on your website.

Since ads within the content are the best performing ones, this placement can have a large impact on the ad revenue, if used correctly.

Injecting an ad into the content

In order to inject an existing ad or ad group into the content of your posts, you need to create at least one Post Content placement. Go to Advanced Ads > Placements and create a new placement with the type represented by the following icon:

ad placement within the content

The placement you will now see in the list should look similar to the one on the next image:

Options to automatically inject an ad into the content on WordPress
Example for a content injection after the second paragraph

In this example, the placement injects our Medium Rectangle ad after the 2nd paragraph on each post.

Ad Injection elements

You can inject ads based on practically any element in the content.

  • paragraphs
  • headlines
  • images (includes galleries)
  • quotes
  • iframes
  • tables
  • list items (<li>)
  • containers (<div>)
  • any element with visible text in it

You can also use the “custom” option to build your own injection rules.

Custom injection rules

The “custom” injection rule comes with a tool to help you pick the position of your ad in the frontend just by clicking on it with your mouse. Just click the select position button to start that tool.

Click on “select position” to start selecting the ad position in the frontend.

A click on “select position” brings you to the last published post on your site. You can navigate to other pages by entering another URL directly or clicking on any link.

The frontend picker allows you to select any element that is technically in the content of your site (tech talk: everything wrapped in the the_content filter). This can be more than just the main blog text if you are using a page builder. The mouse cursor looks different when a position can or can’t be selected.

Here are a few examples on injecting ads using the “custom” option.

  • enter br to inject ads based on <br/> tags or any other specific HTML element
  • enter p/following-sibling::p[1] + set the “before” position to only inject ads between paragraphs and not before any other tags, e.g., images
  • enter *[@class="CLASS"] and replace CLASS with the exact classes of a any element in the content to inject ads next to it

Please note that while ads for most pre-defined options like “paragraph” or “headlines” are only injected if these elements include visible text, the “custom” option also counts elements without any text in them.

You can built more sophisticated rules based on XPath. Please find examples in the XPath cheatsheet.

Advanced Options

These are options added by Advanced Ads Pro to especially extend the functionalities of the Post Content placement.

Repeat the position

Repeat the ad. E.g., if you set it to display after the second paragraph, checking this option would result in the ad to show up automatically after the fourth, sixth, eighth, etc. paragraph as well.

Note: not every ad network might support this. So far, we learned that doesn’t. AdSense works.

Minimum Content Length

Set a minimum length of the content before an ad is injected into it.

Words between ads

This option lets you define a minimum amount of words in a text section that is necessary before an ad will be injected. The option “Words between ads” will not inject an ad when the number of words after the last injected ad is less than the defined value. This includes paragraphs, headlines, and other text elements.

Prevent ad injection into the content

Pro adds a setting to the Ad Options meta box on the post and page edit pages to disable all automatic content injections for that specific page in the frontend.

General Settings

Change the order of injected elements

By default, Advanced Ads tries to inject ads to the post content as late as possible. However, this might not always be your attention. To change the priority of the injection, use the following option in Advanced Ads > Settings > General.

content injection priority option

Tip: Most injections have a priority between 1 and 20, so when trying to find the right value, start with 10 or 20.

Unlimited ad injection

Some plugins and themes trigger ad injections where it shouldn’t happen. Therefore, Advanced Ads ignores injected placements on non-singular pages and outside the loop. However, this can cause problems with some themes. Set this option to -1 in order to enable unlimited ad injection at your own risk, set it to 0 to keep it disabled or choose a positive number to enable the injection only in the first x posts on your archive pages.

You find this setting in Advanced Ads > Settings > General.

Unlimited ad injection setting

Custom solutions

Here are some custom solutions for issues with the content injection placements.

Prevent injection into specific elements

You can prevent automatic ad injection into specific elements by adding the .advads-stop-injectionclass.

You can add your own elements with the custom code explained here.

Ad injection without the_content()

If your theme can not use the the_content function, but get_the_content() or a similar approach, you can apply the ad injection manually using a line like this in your theme:

echo Advanced_Ads::get_instance()->inject_content( get_the_content() );

Ad injection with a different filter

You can use ad injection on content that uses a different filter, too, when Advanced Ads Pro is enabled. Just set the ADVANCED_ADS_PRO_CUSTOM_CONTENT_FILTER constant in your wp-config.php like in the example below. Replace YOUR_FILTER with your filter string.



The content injection can break for various reasons. Mostly, because of a broken ad code or when the paragraphs can not be counted due to a broken tag. Such issues will be captured in the error log or displayed below the ad when you have WP_DEBUG enabled in your wp-config.php.