Insertion before or after paragraphs is one of the most commonly used functions of the plugin. Paragraph settings allow you to very precisely define what is considered as paragraph, how they are counted and where should insertion be avoided.
Please check all the available paragraph settings in order to get the most out of the plugin.
Here you define paragraph number(s) for Automatic Insertion options Before and After Paragraph:
- value 1 or more means paragraph number
- negative value -1 or less means paragraph number counted from the opposite direction as configured
- value between 0 and 1 means relative position in post or page (e.g. 0.3 means paragraph 30% from top or bottom)
- 0 means random paragraph position
- Empty value means all paragraphs – use Filter to define insertions
You can also specify comma separated list of paragraph numbers for multiple insertions.
Paragraphs can be counted from top or from bottom. It is also possible to count only paragraphs that contain or do not contain certain text or count only paragraphs that have some minimum or maximum number of words. If more than one text is defined (comma separated) and contain is selected then the paragraph must contain ALL texts.
Paragraphs are not counted inside special elements:
<blockquote>, <figure>, <li>. There is an option to enable counting also inside these special elements and you can define these special elements – No paragraph counting inside setting (tab ⚙ / tab General).
Paragraph processing works on every post or page according to settings. Therefore, if you enable insertion also on blog pages (home, category, archive, search pages) and your theme does not display post excerpts but complete posts, Ad Inserter will by default insert code blocks into ALL posts on the blog page (according to settings).
You can also define paragraph HTML tags. Normally only
<p> tags are used. If your post contains also
<div> or header tags, you can define comma separated list of tags used to count paragraphs (e.g. p,
div, h2, h3).
Each code block you insert adds wrapping
<div> element around the block code unless you use No wrapping style. Before Paragraph will insert the code before specified
<tag>, After Paragraph will insert the code after closing
After Paragraph will work even if you specify tag names that have no closing tags (e.g. images using
<img> tag) since Ad Inserter uses special processing for such cases. Use
# as tag if paragraphs have no tags and are separated with the
Minimum number of paragraphs defines minimum number of paragraphs that post must have in order to enable insertion. Leave empty for no limit.
Minimum number of words in paragraphs above is an alternative way to insert ads only after some amount of text above. Leave Paragraph number(s) empty and define minimum number of words in paragraphs above. The block will be inserted between paragraphs where the number of words in paragraphs above the insertion is above this limit.
You can also define parameters to avoid insertion at paragraph positions where above or below there is some unwanted element (heading, image, title). This is useful to avoid inserting ads where they may not look good or where it is not allowed.
You can define in how many paragraphs above and below should the specified text be avoided. And if the text is found you can choose to either skip insertion or to try to shift insertion position up or down up to the specified number of paragraphs.
When logged in as admin there is admin toolbar displayed on the top of every post and page.
Ad Inserter menu item has few debugging functions which can help you to see HTML tags and positions for automatic insertion with particular paragraph counting settings.
- Show HTML Tags visualizes HTML tags
- Show Positions shows available positions for automatic insertion.
Function Show Positions uses one of the configured paragraph settings for blocks configured for automatic insertion After or Before paragraph. Make sure you select the right paragraph counting settings (Show Positions sub-menu).