Post Loops: getting and displaying posts

LiveCanvas allows you to retrieve data from posts (or custom post types) in a clean and powerful way, and to flexibly display data.

A typical use case for this is when you need to list the latest blog news on your homepage.
Let's dive into a practical example.

Creating a post loop with the visual query builder

Let's use a readymade section.

In the visual editor, click the  "Add Section" button.

A side panel is revealed:

As in the screenshot above, you should see the "LiveCanvas Library".

If you don't see that library, you might be running a child theme with a custom UI kit -  but no problem, you can easily switch to the "LiveCanvas Library", clicking the cog icon and selecting the "LiveCanvas Library".

Click on the "Dynamic Post Loops" category.

Now select your favourite starter. We chose the second example.

You should  your latest posts by now in the page preview.

This is how it looks like:

Upon clicking on the element, you'll see an interface that allows you to customize the query parameters.

Here is what the panel looks like:

How to Customize the output of your Posts Loop

Have a look at the HTML code of the section. The query information and the output view is clearly readable!

Note: Just right-clicking the blue "Section" label on the page will directly show up the code editor, if you're lazy and want to skip the contextual menu.

From LiveCanvas v4 on, you'll see the "tangible" tag, and a special syntax which is the "Loops and Logic" syntax.

This syntax handles directly the post loop templating inside the code, so it's super easy and intuitive to customize the post loop output markup.

 

Read more about the Loops and Logic syntax on this page.

[NOTE FOR OLDER SITES: If you're  still using the "lc_get_posts" shortcode - which while still working perfectly, it's not the most powerful way, but you can find the LEGACY documentation here]