Skip to toolbar

BEFORE and AFTER

Provides the ability to run a opening block in your template that will be output BEFORE and AFTER the loop.

Overview

The [before] and [after] Template tag blocks are used to output a piece in your template that will only be output before the ‘loop’ portion of the template and after it. This is primarily used for Table heading blocks <table><thead></thead><tbody>(and table ending blocks </tbody></table>) and the opening Un-ordered List <ul> and closing un-ordered list </ul>. NOTE: Magic Tags are not processed inside the Before and After blocks, so they cannot be used to provide ‘totals’ or ‘counts’ or anything else of that nature.

Usage

You also have access to [before] and [after] blocks. These can be used to set code that runs before or after all iterations of a template. This means that if you call a template in a against a loop or using the Pods shortcode, so that it is used to show multiple items, the [before] and [after]blocks will only run once.

This avoids the issue where the shortcode

 

 if it called a template like this:

Would output:

That template could be rewritten as:

Which will result in: