Skip to main content
All CollectionsDynamic ShortcodesDynamic Shortcodes Types
How to Loop Posts with Dynamic Shortcodes
How to Loop Posts with Dynamic Shortcodes
Updated over a week ago

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.


{loop:array-of-post-id-here template @ sep=','}

  • array-of-post-ids An array of post IDs to loop over. These IDs can be provided by another Dynamic Shortcode like query, or directly specified using {array} with explicit IDs that represent valid posts within your WordPress database.

  • template The template to be printed at each iteration. This can be a complex template or a single Dynamic Shortcode.


  • separator (alias sep): 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.


Display a list of links to posts.

[<li><a href="{post:permalink}">{post:title}</a></li>]}

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.

@sep=', '
Did this answer your question?