Get and Set

The Get and Set tags are useful for remembering a value to use later, or in multiple places.

This is commonly called a "variable", which has a unique name and holds a reference to a value.

Set

Use the Set tag by giving it a name where to save the value.

In the example below, the current post ID is stored in a variable called current_id.

<Set name=current_id>
  <Field id />
</Set>

Get

Use the Get tag with a variable name to get the value.

<Get name=current_id />

Variable types

In addition to regular variables, there are other variable types with special behavior.

These can be accessed by using an attribute name of the variable type, instead of the name attribute.

For example, to get the site URL:

<Get url=site />

Most of the variable types have a tag as a shortcut. The above is equivalent to:

<Url site />

For details, see the page for each variable type.

Template variable

The template variable type is useful for storing templates, then rendering them later, or in multiple places.

This is in contrast to regular variables, which are rendered upon setting them.

For example, to create a reusable template:

<Set template=title_and_content>
  <h1><Field title /></h1>
  <Field content />
</Set>

It can be used anywhere, such as inside a loop.

<Loop type=page count=1>
  <Get template=title_and_content />
</Loop>