Does your website use advertising? Did you know you can insert adverts between posts? This tutorial will show you just how to do that.
If your website leverages WordPress ads, the announcement about a new shortcode for incremental content in version 3.0 will have caught your attention. This tutorial will show you how to maximize this shortcode, and insert ads between posts in Formidable Views, both incrementally and recurring.
This feature was born from user requests wanting to know how to add custom ads within the content.
Some users wanted an advert after three entries, and maybe another after the tenth entry. Some wanted to add layout elements after specific entries to build a custom page grid or design. Or others wanted the first entry to show different content or different styling.
Do you have a business directory and want to show a banner ad after every 5th business listing? With this feature, you can do just that. Read on to find out how you can insert ads within your post content in WordPress and how to add custom ads in WordPress.
The ability to add incremental content or adverts in Formidable Views has many benefits. We were delighted to announce the [entry_position] shortcode last year. Finally, it's time to give this feature the fanfare it deserves!
Two ways to use incremental content on your WordPress site
There are two ways that you can insert incremental content in Formidable Views. Here's how to place the ad code in between the HTML of your content feed.
On its own, the [entry_position] shortcode can be used to place adverts or extra content in specific positions. This is perfect if you want to highlight the first entry with different styling.
Because the [entry_position] shortcode does not automatically repeat, you will need to add a new condition for each section of content you require.
If you have a lot of entries displayed in your View, you may also want this content to recur automatically.
Another new feature is the ability to combine the [entry_position] and [frm_condition] shortcodes. This means you can set your incremental content to automatically recur, saving valuable time!
How to insert an ad one time within the entry loop
The [entry_position] shortcode gives you a simple way to add extra content at specific positions within your View. It is especially useful for Views that display a small number of entries, and where incremental content does not need to automatically repeat.
Use this code at the bottom of your View content to insert an advert after the 3rd entry:
[if entry_position equals=3]Include an ad here[/if entry_position]
The same method also allows you to highlight or feature the first entry in a View. Add classes or inline styling to specific entries to style your View:
[if entry_position equals=1]<div class="featured">This is the first entry. It gets more space.</div>[/if entry_position] [if entry_position not_equal=1]This is not the first entry.[/if entry_position]
This new shortcode also supports less_than and greater_than conditions. Use these options to feature the first three entries in a View this way:
[if entry_position less_than=4]<div class="featured">This is a featured entry. It gets more space.</div>[/if entry_position] [if entry_position greater_than=3]This is not a featured entry.[/if entry_position]
Recurring, incremental content made easy
If your View displays a lot of entries, regular incremental content would mean lots of added code. Things can get a bit messy if you use a new [entry_position] shortcode for each content insertion.
Automatically recurring, incremental content is the answer!
Combining the [frm-condition] shortcode with [entry_position] allows some interesting possibilities.
To add additional content on every 3rd entry in your View, see the example below. This can be modified to repeat at whatever interval you wish.
[frm-condition source=frm-math decimal=1 content="[entry_position] / 3" like=".0"]This is the incremental content[/frm-condition]
How does it work?
The principle behind this code is that the [entry_position] shortcode will always return a whole number. If you want your incremental content to display every third entry, you simply divide this number by three. This is seen in the "[entry_position] / 3" part of the above code. Feel free to change this number to suit your requirements.
The [frm-condition] shortcode checks this returned value against the like=".0" parameter. When the entry returns a figure matching this parameter, (any whole number), the additional content will be inserted.
Because of the decimal=1 parameter, the first and second entries will return values with a number after the decimal point that do not match the condition. The third entry will return a value of 1.0 which is a match for the like=".0" condition. The value will match for every whole number - in this case that will happen every third entry.
How can ads in Formidable Views power your WordPress site?
Insert adverts between posts in your existing Views with ease! There's no need to redesign or rebuild your Views, because this feature can be dropped directly into your existing system.
We love to see examples of how you've integrated this feature into your website. If you are already using Formidable Forms for WordPress forms, submit your creation to our community showcase and provide inspiration to others building their forms.
Not using Formidable Forms yet? Learn more about the features that make Formidable Forms the best online form builder plugin.