Loops & Logic


Loops & Logic is a toolset that allows you to have extensive control over the display of WordPress content & data on your site’s frontend for when your theme or builder doesn’t have the options you need. This plugin gives you the power of custom PHP theme & builder module development using a simplified HTML-like syntax that will be familiar to any frontend developer.


Key Features

  • Use HTML templates with dynamic tags like Loop, Field, and If
  • Use theme location rules to apply custom templates to post types, taxonomies & more (similar to Beaver Themer or Elementor Theme Builder)
  • Easily enqueue your CSS stylesheets and Javascript anywhere using a visual location rule builder
  • Seamlessly write your CSS directly in SASS without worrying about compilation
  • Create query loops of any content type, such as: posts, pages, custom post types, attachments, users, taxonomies and terms
  • Display built-in and custom fields
  • Build logic to display things based on certain conditions, for example: creating a menu, with some links only for logged-in users, or by user role
  • Create custom shortcodes to display anything from a custom field to an entire dynamic-data driven web page

Example Usage

At the core of L&L is the ability to quickly and elegantly loop through WordPress data like in this example of displaying a list of links to the three most recent posts

  <Loop type=post count=3 orderby=date order=desc>
      <a href="{Field url}"><Field title /></a>

Accomplishing the same thing in PHP is a little more complex:

$args = array(
    'post_type' => 'post',
    'posts_per_page' => 3,
    'orderby' => 'date',
    'order' => 'DESC',
$query = new WP_Query( '$args' ); ?>
<?php if ( $query->have_posts() ) : ?>
    <?php while ( $query->have_posts() ) : $query->the_post(); ?>

        <a href="<?php the_permalink(); ?>">
          <?php the_title(); ?>

    <?php endwhile; ?>
<?php endif; ?>

It can be difficult to add PHP to your site if you’re not a backend developer, but L&L is a breeze to include, even in a page builder layout.

Page builders like Gutenberg, Elementor, and Beaver Builder often have gaps in their capabilities that would normally require you to either develop a custom add-on or purchase a bloated add-on pack just to get the one element you need. L&L adds 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. You can even copy-paste your L&L code between page builders if you work with more than one! It’s like having your own page builder addon factory.

Plugin & Theme Support

Plugin Support:

Loops & Logic works with the post types and custom fields added by most plugins, but plugins with special data structures like a custom tables or fields with data formats that need parsing require us to program explicit support.

Bundled integrations:

✅ Advanced Custom Fields (ACF)

L&L supports Advanced Custom Fields (ACF) field types in the core, allowing you to work with most of their field types out of the box! We also plan to support other WordPress custom field plugins such as Pods & Metabox in the future.

<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}" />


✅ WP Fusion

The freely-included WP Fusion integration allows you to use conditional logic to protect or display different content based on a user’s tags.

<If user_field=wp_fusion_tags includes value="123">
  User has tag ID 123
<Else />
  User does not have tag.

We’ll be rolling out premium addons for popular plugins in the coming months, so check out our website to see what’s available!

Premium addons coming soon:

  • WooCommerce
  • Easy Digital Downloads
  • Modern Tribe Events Calendar
  • Gravity Forms
  • LearnDash
  • LifterLMS

Theme Support:

Everything will work with themes built according to WordPress standards.


This plugin provides 1 block.

  • Loops & Logic


  1. Install & activate in the admin: Plugins -> Add New -> Upload Plugins


July 26, 2021
This has become my default plugin. I hope more and more people will share its usage. For beginners, it is best to list all tags or index tags directly in the appropriate place for quick selection. If possible, I hope to add multi site options in the future. For example, all sub sites enable the same section of CSS / JS, which does not have to be set in each sub site.
June 28, 2021
As a designer (read "person regularly mystified by lines of PHP") I found this plugin useful in achieving what I could not do with my page builder of choice. I feel like I'm only scratching the surface of what this plugin can do, but am eager to learn more. I hope they add more examples to the documentation. My thanks to the developer(s).
May 23, 2021
I had some time to play around with this plugin yesterday. It reminds me of the old days using iTheme’s LoopBuddy plugin. I found the Loops & Logic plugin documentation to be fantastic and well organized. It think having a place to share code snippets with the community would help make this plugin use grow. Right now, I can see the learning curve being too much for some people to grasp how to use the plugin, so a collection of code snippets examples would likely help. I’m adding this plugin to my default stack. Great work!
May 21, 2021
Full disclosure: I work for Tangible I've been using Loops & Logic on site builds for several months (while it was in beta) and it's been a joy to use. I'm not particularly good with PHP, so this saves me a lot of copy-pasting and tweaking snippets from stackoverflow when I want to make a complex loop (especially for users and taxonomies!!).
Read all 5 reviews

Contributors & Developers

“Loops & Logic” is open source software. The following people have contributed to this plugin.


Translate “Loops & Logic” into your language.

Interested in development?

Browse the code, check out the SVN repository, or subscribe to the development log by RSS.



Release Date: 2021-12-22

  • Universal ID – Unique and immutable across sites
    • Implement for all template types
    • Dynamic blocks in supported builders
    • Import/export
  • Exporter: Save and restore settings from browser local storage
  • Gutenberg integration: Disable links in blocks when inside editor preview (Elementor and Beaver already does this by default)
  • Format tag: Correctly trim by length
  • Form tag: Improving default content type action “create”; Add redirect on success/error
  • Add ACF field type “Tangible Message” – Based on default message field, it renders a template instead of plain text
  • Add build script to remove sourcemap comment from vendor libraries used for CodeMirror editor


Release Date: 2021-11-26

  • Loop pagination: Automatically pass variables used in inner template
  • Fix typo in importer message for “Layouts”
  • Improve handling when block control config type is empty
  • If tag: Improve handling when else node has no attributes property


Release Date: 2021-11-18

  • Location field for Layout template: Improve updating selected rule parts on initial render
  • Field tag: Add attribute “custom” to get custom field whose name overlaps with an alias, for example, “name”
  • Start Form module – Work in progress
    • Add Form tag with local tags: BeforeSubmit, Success, Error, Mail
    • AJAX form handler
    • Form actions with dynamic variables and templates


Release Date: 2021-11-11

  • Make template assets map available as Sass and JS variables (See “Assets” tab for documentation)
  • Taxonomy term loop: Add query parameter “name” as alias of “include”
  • Improve user access control for Template module
  • New templates are assigned “universal ID”, which is unique and immutable across sites


Release Date: 2021-11-02

  • Add Exit and Catch tag
  • Add variable types: local, sass, and js
  • Template tag and shortcode: Pass attributes to template as local variables
  • Update CodeMirror library: Relax lint rules for Sass “property-sort-order” and HTML “id-unique”
  • Improve admin menu organization


Release Date: 2021-10-20

  • Add menu loop type
  • Calendar loop types
    • Add “year” loop
    • Add “locale” attribute to translate names
    • Add “format” attribute for field “date”
    • Add fields: name, short_name, month_with_zero, week, weekday


Release Date: 2021-10-07

  • ACF fields: Add special subfields for getting field config, such as labels and choices
  • Base loop: Improve handling of query argument “count”
  • Template editor: Solve Gutenberg issue with keyboard shortcuts


Release Date: 2021-09-30

  • Template editor improvements
    • Scope all CSS styles under wrapper class so editor can co-exist with other instances of CodeMirror
    • Implement line wrapping feature
    • Document common keyboard shortcuts: https://loop.tangible.one/overview/template-editor
    • Update CodeMirror add-ons and modes


Release Date: 2021-09-29

  • Url tag: Support attribute “query” without value
  • Improve welcome message; Add link to new documentation site
  • Move WP Fusion integration from Pro plugin


Release Date: 2021-09-22

  • Improve escaping outputs
  • CodeMirror editor improvements: Update dependencies; Implement code folding add-on; Improve close tag add-on behavior


Release Date: 2021-09-15

  • Importer: Ensure escape characters are preserved in template fields
  • Base loop: Improve field_compare=exists to recognize loop instance


Release Date: 2021-09-07

  • Initial release of Template Assets feature to import/export media attachments
  • Clear compiled styles when Style field is empty
  • Add loop type “acf_group” for ACF group field
  • Add field “acf_key” to get field by ACF key
  • Export: Add setting for package name
  • Attachment loop: Add field “mime” for MIME type


Release Date: 2021-09-05

  • Importer: Show links to newly created templates
  • Loop default context: Improve checking if we’re already inside current post content
  • Beaver Builder integration: Improve checking if current post is being edited in the builder
  • Add workaround to preserve escape characters in template fields


Release Date: 2021-09-01

  • Chart tag
    • Add ticks options – percentage, before text, after text
    • Add tooltip values
    • Add data labels


Release Date: 2021-08-19

  • Improve support for nested ACF flexible content and repeater fields
  • Post Loop: Improve query by raw field value
  • Base Loop: Improve filter/sort by field


Release Date: 2021-08-10

  • Import/export templates
  • Support third-party integrations


Release Date: 2021-07-20

  • Add template include filter for Layout templates
  • Prepare interface for third-party integrations, including Loops & Logic Pro
  • ACF “editor” field type (WYSIWYG): Format field value by default


Release Date: 2021-07-16

  • Simplify logic to reliably prevent infinite loop for default loop context and post content in general


Release Date: 2021-07-10

  • Loop module: Improve logic to prevent infinite loop, when using default loop context (global $wp_query)
  • Gutenberg and Elementor integration: Improve handling template style/script


Release Date: 2021-07-01

  • If tag: Add ACF field type conditions, such as acf_checkbox, acf_relationship, etc.
  • Taxonomy and taxonomy term loop: Improve sort by custom field


Release Date: 2021-06-30

  • Taxonomy term loop: Add query parameters “hide_empty”, “orderby_field”, “orderby_field_number”; Add field “count”
  • Template post types: Add “name” field (post slug) in admin edit screen and Template tag
  • Template tag: Add “theme” attribute to load theme templates: sidebar, search, and part
  • Layout post type: Add “Theme parts” settings to load alternate header or footer
  • Loop tag: Add logic to prevent infinite loop when a post loads itself; Improve handling default loop context (global $wp_query) when used without “type” attribute, especially in the context of Beaver template and layout


Release Date: 2021-06-22

  • Add ACF field type “Tangible Template” (under Content section)
  • Add template types Style, Script, and Layout, with theme location rules builder
  • Gutenberg, Elementor, Beaver Builder: Add ability to select from saved templates
  • Field tag: Add attributes “template” and “acf_template” to render Template field
  • If tag: Add conditions for main query: “singular” and “archive” (category, tag, taxonomy, post, author, and date)
  • If tag: Add common operators “in” and “not_in” to check if value is in given list
  • Template tag: Add attribute “type” for layout, style, script, block


Release Date: 2021-06-10

  • Attachment Loop: Add fields “srcset” and “sizes” for responsive image attributes
    • For featured image in post loop, the field names are “image_srcset” and “image_sizes”
  • Field tag: Add attribute “item” to get an item from a list, using index starting with 1
  • Meta tag: Support “viewport” attribute


Release Date: 2021-06-02

  • Chart tag: Add options chart_title, chart_legend, axis_x, axis_y
  • HTML module: Improve handling JSON object and array in tag attributes
  • Template shortcode: Support passing template as inner content


Release Date: 2021-05-21

  • Publish to WordPress plugin directory