What are Data variables?
Data variables allow you to dynamically display content from different sources – such as Posts, Pages, Custom posts, Authors and Taxonomies (such as Categories or Tags) – inside your layouts.

Selecting the source
To get started with data variables, you first need to select the source of your data. If you want to create an entire page for that source, choose the appropriate Template type. If you only want a part of the page to display data from the source, use one of the available Element options.
Template type
When creating a new template, you can choose a Template type. Some template types are specifically designed to work with data variables; these are listed below.

Single template types
“Single” template types, such as Single post, Single page, or any Single custom post type allows you to define a layout that controls how all items of the selected type – posts, pages, or custom posts – are displayed.
Archive template types
“Archive” template types, like Post archive, Categories archive, Tags archive, etc. are used to display multiple items on a page, such as your latest posts, list of your categories or tags.
Archive fallback
This template type serves as a fallback for Archive templates. For example, if you have multiple post or custom post types – such as news articles, blog posts, tutorials – and you don’t want to create a separate Archive template for each one, you can use the Archive fallback to define a common layout for all of them.
Element
Loop element
The Loop element allows you to select a source, like Filtered posts, categories or tags, and display multiple items next to each other. You can use a Loop element in any template type, and it can have its own source.

Div element
At the Settings of Div, Container, Rows, Columns, Grid elements you can find a Dynamic sources option. Here, you can select any source – such as a specific post, category, or tag. Once a source is selected, all elements inside the Div, Container, or other parent element will be able to use variables from that source.

Post content element
The Post Content element is a special element, which was created to basically just hold the post’s Content variable. You can edit its design through the Gutenberg Styles.

Using variables
Many elements – such as Text, Image, or Video – and fields in the Style tab, like Background color or Background image, include a variable selector.

Based on your source, clicking this icon will bring up the available dynamic data variables, such as the Title or Content of a page/post.

By default, only those Type options are selected that are most relevant to the current element. For example, in image-related fields, the post’s Featured image variable is available, while the Title variable is hidden.
However, when using functions such as Find_image or Find_link, you may want to access variables that are hidden by default. In these cases, make sure to enable the appropriate Type options to reveal all available variables.
Available post variables
You can use the following types of post based variables in your templates and elements:
- Post data – The default data of posts: id, title, content, featuredImage, permalink, excerpt, etc.
- Author data – The default data of authors: id, description, avatar, permalink, etc.
- Taxonomy data – The default data of taxonomies (categories, tags, other taxonomies): id, name, description, permalink, etc.
- Custom metadata – All metadata fields that do not start with an underscore (
_) character, including custom fields created with third-party plugins (see Custom fields).
Custom fields
Mosaic reads custom fields from popular third-party plugins and turns them into data variables you can use just like the built-in ones. See the dedicated guide for each:
Functions
The variable selector provides several functions for modifying variables. A function starts with an @ sign, followed by its name and its parameters in parentheses. Parameters can be variables, text in quotes, numbers, or other functions.
In the function list, each function includes a short description, and optional parameters are shown in square brackets. All available functions are listed below.

Abs
Returns the absolute value of a number, which is the number without its minus sign.
Example:
@ABS(-12)
Returns 12.
Attachment
Returns the URL of a WordPress media attachment based on its ID. Optionally, you can request a specific registered image size.
Examples:
@ATTACHMENT(@VAR('post/meta_my_image_id'))
Returns the full-size image URL of the given attachment.
@ATTACHMENT(@VAR('post/meta_my_image_id'), 'thumbnail')
Returns the thumbnail-sized version of the image.
Avg
Returns the average of the given numbers. Text values are ignored.
Example:
@AVG(10, 20, 30, 40)
Returns 25.
Calc
Calculates the result of a mathematical operation. You can use the +, -, *, / and % (remainder) operators. The + operator only adds numbers; to join texts, use Concat.
Examples:
@CALC(10 % 3 + 2)
Returns 3: the remainder of 10 divided by 3 is 1, plus 2.
@CALC(@DATE('Y') + 1)
Displays the next year. For example, if the current year is 2026, it shows 2027.
Concat
Joins several texts or numbers into one text. Outside of functions, you can simply write text next to a variable; Concat is useful when you need to pass the joined text to another function.
Example:
@FALLBACK(@VAR('post/featuredImage'), @CONCAT('https://xy.com/fallback-', @DATE('Y'), '.jpg'))
Uses the post’s featured image if available; otherwise, it displays a fallback image whose URL contains the current year, for example https://xy.com/fallback-2026.jpg.
Date
Formats a date using the specified format. If no timestamp is provided, the current date and time are used. By default, the date is shown in your WordPress site’s timezone; pass 1 as the third parameter to show it in GMT instead.
Examples:
@DATE('Y')
Displays the current year.
@DATE('Y-m-d', @VAR('post/publish_timestamp'))
Shows the post’s publish timestamp as a date with Year-month-date format.
Esc_attr
Escapes special characters (&, <, >, " and '), so the value can be safely used inside an HTML attribute.
Example:
@ESC_ATTR('Tom & Jerry')
Returns Tom & Jerry.
Esc_html
Escapes special characters, so HTML code is displayed as text instead of being rendered.
Example:
@ESC_HTML('<strong>Hello</strong>')
Displays <strong>Hello</strong> as plain text, instead of a bold “Hello”.
Excerpt
Shortens text to the given number of characters. If the text was shortened, ... is added to its end. Words are not cut in half: the text ends at the last full word.
Optionally, you can set a different ending as the third parameter. If your language doesn’t use spaces between words (for example, Chinese), pass 1 as the fourth parameter to allow cutting inside words.
Examples:
@EXCERPT(@VAR('post/content'), 100)
Returns the first 100 characters of the post content, ending at a full word.
@EXCERPT(@VAR('post/content'), 100, ' [more]')
Same as above, but the shortened text ends with ” [more]” instead of “…”.
Fallback
Returns a fallback value if the given variable is empty or 0. This is useful to ensure that an element always has content.
Example:
@FALLBACK(@VAR('post/featuredImage'), 'https://xy.com/fallback.jpg')
Uses the post’s featured image if available; otherwise, it displays the specified fallback image URL.
Find_image
Searches for image URLs within a text-based variable and returns the specified match. It finds both images and CSS background images. If you leave out the second parameter, the first image is returned.
Example:
@FIND_IMAGE(@VAR('post/content'), 1)
Extracts the first image found in the post content.
Find_link
Searches for links within a text-based variable and returns the URL of the specified match. If you leave out the second parameter, the first link is returned.
Example:
@FIND_LINK(@VAR('post/content'), 2)
Returns the URL of the second link found in the post content.
Find_video
Searches for videos within a text-based variable and returns the URL of the specified match. If a video has several sources, the MP4 source is preferred. If you leave out the second parameter, the first video is returned.
Example:
@FIND_VIDEO(@VAR('post/content'))
Returns the URL of the first video found in the post content.
Json_encode
Converts a value to JSON-formatted text. This is useful when a variable holds a list of values, for example a custom field with multiple values.
Example:
@JSON_ENCODE(@VAR('post/meta_my_colors'))
Returns the values of the my_colors custom field as JSON text, for example ["red","green","blue"].
Remove_html
Removes all HTML tags from the given variable, returning plain text only.
Example:
@REMOVE_HTML(@VAR('post/content'))
Strips HTML formatting from the post content.
Round
Rounds a number to the nearest whole number.
Example:
@ROUND(12.5)
Returns 13.
Round_up
Rounds a number up to the given number of decimal places. If you leave out the second parameter, it rounds up to a whole number.
Examples:
@ROUND_UP(12.567, 2)
Returns 12.57.
@ROUND_UP(12.01)
Returns 13.
Substr
Returns a part of a text, from the start position up to, but not including, the end position. Positions start at 0. If you leave out the end position, the rest of the text is returned.
Example:
@SUBSTR('Mosaic Builder', 0, 6)
Returns “Mosaic”.
Sum
Adds the given numbers together. Text values are ignored.
Example:
@SUM(1, 2, 3)
Returns 6.
Mixing functions
Functions can be nested to combine their effects.
Example:
@EXCERPT(@REMOVE_HTML(@VAR('post/content')), 100)
Removes HTML tags from the post content, then creates a 100-character excerpt from the cleaned text.
How to insert variables from the next/previous post?
In Single template types, if you want to display variables (title, featured image, date, etc.) from the previous or next post, you can build the source directly in Mosaic. The idea is to point a Div element at a single post — the previous or next one — and then use that post’s variables inside the Div.
Previous post
- Add a Div element.
- On its Settings tab, click the + icon next to Dynamic sources to define a source for the contents of the Div.

- For the Source, select your post type (e.g. “Posts”, or your custom post type).

- Click the + icon next to Filter, and add a rule for the Post variable type:
- Post variable key: Published date GMT
- Operator: before (from the Date group)
- Value: hover over the Value field and click the Dynamic data icon above it. Select the Publish timestamp variable, then click Insert dynamic data.

- Your filter rule should now look like this. Click Apply filter.

- Click the + icon next to Order by, and add a Post variable rule:
- Post variable key: Published date
- Order: Descending

- Now insert any element inside this Div, and select a variable for it, for example the Title. It will show the previous post’s data.

Next post
Follow the same steps as above, with two differences:
- In the Filter rule, set the Operator to after (from the Date group).
- In the Order by rule, set the Order to Ascending.
Hide navigation when there is no previous/next post
You can hide the elements inside the Divs when no previous or next post exists by adding a Conditional visibility rule — for example, by checking whether the post ID from the source defined by your Div is greater than 0.
