Skip to main content

i4w_foreach

Usage

This shortcode is used to perform a set of repetitive actions a fixed number of times, based on values passed to it, similar to a programming FOREACH loop.

[ELSE_foreach] conditional branching is NOT supported.

Shortcode nesting is NOT supported.

Parameters

ParameterDescriptionDefaultRequired
setThis parameter defines a set of comma separated (default) values passed to the shortcode, for each of which an iteration will be performed. The value set may include words or phrases, but may not include commas, unless a different separator is assigned.NoneYes
separatorDefines the separator to use in order to separate the values passed to the shortcode.commaNo

Example

Shortcode
[i4w_foreach set='5,12,57,31,78']
Going thru the loop; this time the value is %%value%%
[/i4w_foreach]

All actions between the shortcode tags would be performed 5 times, once for each value in the "set". The internal variable placeholder, %%value%% is updated at each iteration.

Notes

warning

Please consider the effect a large number of iterations could have on the performance of your site.