Home/ Documentation/ WordPress/ Actions/ Smart Actions/ Post & Loop – Smart

Post & Loop – Smart

Display the loop with all returned posts. Includes support for custom WP_Query and Custom Post Types.

For every page view, WordPress returns one or more posts that should be displayed on the view. For the home page it might return the last ten posts. For a single post view it returns a list of posts with just the selected post. For a page view it returns the single page.

When we’re talking about posts here, we’re referring to all different post types, like posts, pages, attachments and custom post types.

The Loop is a PHP code construct that goes through all returned posts and displays or processes each one of them.

This is how the Loop code looks like:

With Pinegrow we don’t have to write and maintain this code by hand. The Post & Loop – Smart action does all the work for us.

Let’s take a look at how it is used.

The Default Loop

The Post & Loop – Smart action without any parameters displays the default WordPress loop that goes through all posts returned by WordPress for the current template page.

We usually add this action on the element that represents the post, for example the <article> element.

Watch the video course to see how Smart actions are used in practice.