Plugin of the Month: Loops & Logic to Easily Display Dynamic Content

  • Reviews, Plugins

It is time for us to introduce another WP-Plugin of the Month that will make your life easier. Meet Loops & Logic – a plugin we believe will be helpful to technical people, especially front-end developers. 

Loops & Logic Plugin

Loops & Logic plugin allows you to have extensive control over the display of content and data on your WordPress site. Basically it is a template system using a simplified HTML-like syntax that will be familiar to any frontend developer.  

It brings together three concepts:

  • Content loops
  • Conditional logic
  • A template language

“We built this plugin to give our own developers the ability to build dynamic websites without needing to touch any PHP and it’s allowed us to take on much bigger projects than we could before. Displaying dynamic content is just the tip of the iceberg of what Loops & Logic can do so I’m excited that other freelancers and agencies can also streamline their site builds like we have. Anybody interested in the future of L&L, Gutenberg and page builders should come take a look at our beta program!”

– Gabriel Gallagher (CEO @ Tangible INC)

Now let’s take a look at the concept of loop, logic and template. 

Loop

A loop can be created from any content type on a WordPress site. Supported content types include posts, pages, custom post types, attachments, taxonomies, users. It’s a standard interface to query for items of any type, and loop through each one to get or display its fields.

Logic

Logic is used to display something based on certain conditions. For example, creating a menu with some links, only for logged-in users or for certain user roles. There is a library of defined logic rules, to cover common use cases.

Each rule is made of three parts.

  • Field – Subject of the condition, like user or user_role
  • Comparison – exists, includes
  • Value – administrator

Template

Loops & Logic uses a custom post type called template. A template is written in HTML, and extended with dynamic tags. L&L markup is always written within a template, whether that’s in the WP admin under Tangible > Templates or directly in a page builder using the Tangible Template block. 

How it works

Loops & Logic plugin provides 1 block – Tangible Template and helps you with displaying your content on the frontend. For example, let’s look into how to display the five most recent posts with featured image and excerpts in your blog.

After installing the plugin, Go to Tangible > Templates from the Menu and click ‘Add New’.

Loops & logic - Tangible templates

Then use this template (works best with Blocksy theme)

<div class="entries recent-entries" data-archive="default" data-layout="grid" data-cards="boxed">
  <Loop type=post count=5 orderby=date order=desc>
    <article class="entry-card">
      <h2 class="entry-title">
        <a href="{Field url}">
          <Field title />
        </a>
      </h2>
      <Field image />
      <div class="entry-excerpt">
        <Field excerpt />
      </div>
    </article>
  </Loop>
</div>

Now add the template and save all the changes.

Loops & Logic - adding new templates

The recent posts will be displayed in the frontend like this.

Integrations

The plugin is compatible with Advanced Custom Fields (ACF) allowing you to work with most of their field types out of the box. For example

<Loop acf_flexible=field_name>
  <If field=layout value=layout_1> Layout 1 <img src="{Field acf_image=field_name field=url}" />
    <Field acf_editor=field_name />
    <Else if field=layout value=layout_2 /> Layout 2
    <Field acf_editor=field_name />
    <img src="{Field acf_image=field_name field=url}" />
  </If>
</Loop>

Our Verdict

We are impressed with the plugin especially when it comes to getting over the limitations of the theme options. Also if you are not a backend developer with a strong PHP base, this plugin can help you tinker around with your theme/page builder. You can add a template editor module directly to each builder so that you can simply describe what you want to display in L&L code and place it using the builder interface. Premium addons for popular plugins are in the pipeline and we can’t wait to try them out. 

Previous Plugins of the Month – Turbo Admin, Image Gallery BlockSuper List Block

The WP Week Newsletter

A weekly newsletter covering updates from the WordPress ecosystem that are relevant and helpful for WordPress agencies, developers, and enthusiasts

Leave your comment

Your email address will not be published. Required fields are marked *