With the Loop Dynamic Shortcode you can comfortably loop over posts by setting the current post at each iteration. Freeing you from the need to reference the post ID when displaying its data.
If you want to loop over something other than WordPress posts use the for
instead.
Syntax
{loop:array-of-post-id-here template @ sep=','}
template
The template to be printed at each iteration. This can be a complex template or a single Dynamic Shortcode.
Keyargs
separator
(aliassep
): Defines a string to separate each iteration's output. The default is an empty string, but you can specify separators like commas, spaces, or HTML tags to suit your layout needs.
Examples
Display a list of links to posts.
<ul>
{loop:
{query:posts}
[<li><a href="{post:permalink}">{post:title}</a></li>]}
</ul>
This example demonstrates how to use the Loop Dynamic Shortcode to fetch and display post titles from a generic query, with a separator between each title. This method is particularly useful when you want to display a list of titles in a single line or within a specific formatting context.
{loop:
{query:posts}
[{post:title}]
@sep=', '
}