Automatic Insertion Between Paragraphs
<p>This page demonstrates Ad Inserter automatic insertion between paragraphs. For this purpose we’ll use automatic insertion before paragraph but we’ll not specify paragraph numbers directly, we’ll use Filter for this purpose. We’ll insert ads before every third paragraph and we’ll also count <code><ul></code>
elements below (list with bullet points) as paragraphs.</p>
<p>Paragraph is a section of text between listed tags (normally only <code><p></code>
tags are used). Paragraph counting can be from the top (default) or from the bottom of the page. You can also define what is counted as paragraph (button Counting) and where to avoid insertion (button Clearance), but for this demo we’ll use default values.</p>
![](https://via.placeholder.com/468x60/0000ff/ffffff.png?text=Ad%20Inserter%20DEMO)
<p>Paragraph number(s):</p>
- <ul style="text-align: justify;">
- <li>value 1 or more means paragraph number</li>
- <li>negative value -1 or less means paragraph number counted from the opposite direction as configured</li>
- <li>value between 0 and 1 means relative position in post or page (e.g. 0.3 means paragraph 30% from top or bottom)</li>
- <li>0 means random paragraph position</li>
- <li>%N means insertion every N paragraphs</li>
- <li>Empty value means all paragraphs – you can use Filter (button Misc / tab Filter) to define insertions like in this example, but you can also use %N also as paragraph number</li> </ul>
<p>With Filter you can define which insertions are enabled – single number or comma separated numbers. <code>%N</code>
filter item means filter every N-th insertion. Filter also works for paragraph counting. Leave Paragraph(s) empty, set filter to Paragraphs and define comma separated list of paragraph numbers where the code should be inserted (%N can also be used). Invert Filter inverts insertion – listed insertions are skipped.</p>
![](https://via.placeholder.com/468x60/0000ff/ffffff.png?text=Ad%20Inserter%20DEMO)
<p>This is useful in many cases where you can’t remove unwanted insertions of the code with other settings, for example:</p>
- <ul style="text-align: justify;">
- <li>If you need to insert ad before the first, third and fifth excerpt on the homepage you simply specify 1, 3, 5 for the filter.</li>
- <li>If you need to insert an ad between the second and third comment and between the fourth and fifth comment on posts you set 2, 4 for the filter.</li>
- <li>If you need to insert an ad every fifth comment on posts you set %5 for the filter.</li>
- <li>In some WP themes hooks (that call Ad Inserter insertion functions) are called more than once. In such case you might get unwanted insertions. Simply set the filter to the number of the wanted call(s). Use debugging function Show positions on every post/page to show available positions for automatic insertion with counters.</li> </ul>
<p>Paragraphs are not counted inside special elements: <code><blockquote>, <figure>, <li></code>
. Of course, there is an option to enable counting also inside these special elements and you can define these special elements – No Paragraph Counting Inside setting on the tab ⚙ / tab General.</p>
![](https://via.placeholder.com/468x60/0000ff/ffffff.png?text=Ad%20Inserter%20DEMO)
<p><span></span>Paragraph processing works on every post or page according to the 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 the settings).</p>
<p><span></span>Each code block you insert in the post adds one <code><div></code>
element (with your code) unless you use No wrapping style. This is important if you count also <code><div></code>
elements as paragraphs.</p>
<p>Before Paragraph automatic insertion will insert code before the opening paragraph <code><tag></code>
, After Paragraph automatic insertion will insert code after the closing paragraph <code></tag></code>
. </p>
![](https://via.placeholder.com/468x60/0000ff/ffffff.png?text=Ad%20Inserter%20DEMO)
<p><span></span>After Paragraph automatic insertion will work even if you specify tag names that have no closing tags (e.g. images using <code><img></code>
tag) since Ad Inserter uses special processing for such cases. </p>
<p><span></span>If you are inserting the same ad on multiple positions on posts (with the same counting and clearance settings) use one code block and specify all paragraph numbers. This will speed up insertion as the post will be processed only once.</p>
<p>The text below (Settings used) is wrapped with a <code><div></code>
and the plugin is configured to not count paragraphs inside <code><div></code>
elements.</p>
<hr />
<h2>Settings used</h2>
<p><img fetchpriority="high" decoding="async" src="https://adinserter.pro/wp/wp-content/uploads/ad-inserter-demo-between-paragraphs.png" alt="ad inserter demo between paragraphs" width="746" height="450" class="alignnone size-full wp-image-1563" /></p>
<p>Whe have inserted all the ads with only one block with automatic insertion set to Before paragraph, no paragraph numbers defined (empty field) and filter set to %3 using Paragraphs counter.</p>
<p>Empty field for Paragraph(s) means all paragraphs that count, Filter set to %3 using Paragraphs counter means insert every 3rd paragraph.</p>
</div><hr />
<h3>Related Pages</h3>
- <ul>
- <li> Automatic Insertion After Paragraph </li>
- <li> Automatic Insertion Before Paragraph </li>
- <li> Paragraph Settings </li>
- <li> Sticky Blocks </li> </ul>