Stand with Ukraine. Fight for freedom and democracy

Donate
Back to contents

JetEngine: Macros Guide

 

From this list you can learn everything concerning the macros codes available to use in JetEngine.

We have created special macros for the JetEngine plugin, allowing certain functions. Using these macros in JetEngine widgets, you will be able to query and display specific information on the page.

You can use the following macros in the Query Builder, Listing Grid, and Dynamic Link widgets. Let’s have a closer look at them.

Also, mind that some of the mentioned macros can be found by pushing the “Dynamic Tags” button next to the desired field. Just look for the “Macros” option in the drop-down list and select the needed one.

NOTE
You can additionally use the Dynamic Visibility feature; although it works with the “Dynamic Tags” button only, for now, the manually typed macros won’t work.

Frequently Used Macros

NOTE
If you are using a Listing Grid widget, make sure you paste the macro in the right tab. For instance, if you deal with the Posts Listing, head to the Posts Query tab; if you work with the Terms Listing, you need to work on the Terms Query tab, etc.

%current_categories% — this macro returns current post categories. To exclude the specific category term from showing up, add the Tax Query query type in the Posts Query block and specify this macro in the Taxonomy: Categories block in the Terms field.

NOTE
The %current_categories% macro works only with the default WordPress categories.

%current_tags% — returns current post tags. To exclude the specific tag from showing up, you need to add a new query item and then select the Tax Query query type and Tags in the Taxonomy field, type this macro in the Terms field and specify IN operator.

%current_terms% — returns current post terms; you may specify a taxonomy to return terms from – %current_terms|taxonomy_slug%. 

If one has a custom taxonomy, this macro helps query the current terms to display the posts related by the terms on the Single post’s page.

%queried_term% — returns the ID of the term on its archive page or in a Listing Item of Terms.

Insert this macro in the Terms field, settings Posts Query block (Type: Tax Query > Taxonomy: Category) in the Listing Grid widget to display related posts from the specific term.

%current_id% — returns the current post ID. Type in this macro in the Exclude posts by IDs field in the Posts Query > Posts & Author Parameters query type of Listing Grid widget to let the query exclude the currently displayed post on the page from the query.

%title% — type in this macro in the Label field of the Dynamic Link widget to get the name of the current post and make it clickable.

%object_id% — get the ID of the current object by pasting the macro in the Label field of the Dynamic Link widget.

%field_value% — choose the needed field from the Source drop-down list and add this macro to the Label field in the Dynamic Link widget to get the field’s value, set to be the Source of Dynamic Link. For example, if you use a meta field with URL as a link source, %field value% returns this link. 

%jet_engine_field_name|meta-field|field_name% — paste this macro in the Label field of the Dynamic Link widget to get the JetEngine meta field key name. Use the actual field name instead of the ‘meta-field’ value.

%jet_engine_field_name|meta-field|field_value% — the similar macro to the previous one that should also be pasted in the Label field. Though, this macro returns the value of the meta field and not its name. Don’t forget to change the ‘meta-field’ value into the actual meta field key.

%current_meta|field-name% — use this macro in the Label field of the Dynamic Link widget if you want to display the value of the specific field.

Mind that macro should look like this: %current_meta|field-name%, where ‘field-name’ is the name of the field you want to pull the data from. 

Also, there’s an opportunity to display posts on the Single page that should be filtered by meta field meaning. Proceed to the Posts Query tab and select “Meta Query” as a Type. Paste the Key (name/ID) of the meta field and complete the Value field with the %current_meta% macro.

%current_meta_string|field-name% — with this macro, you can get comma-separated values from fields that contain arrays. You can use it with the multiple select options or checkbox type with the Save as array option enabled. 

%today% — returns today’s date as a timestamp.

%str_to_time|datetime-string% — turns the value into the timestamp. Paste the needed option instead of the ‘’datetime-string”. For instance, you can paste %str_to_time|10 September 2000% to return the timestamp of this date, or %str_to_time|+ 1 day% to get tomorrow’s date as a timestamp.

%option_value|name_of_option::meta_field_name% — returns the options meta field value.

NOTE
Paste the option page slug instead of the ‘name_of_option’ value; it can be found by proceeding to the Options page and copying the slug in the URL. Also, mind changing the ‘meta_field_name’ into the actual options field name.

Macros for Relations

Find out how to work with the new macros for JetEngine relations in the special guide.

NOTE
The following macros work only with the legacy relations. Legacy relations are those that were created before the JetEngine 2.11.0 update.

%related_children_from|post-type-slug% — this macro code is used for displaying only the child-related posts. You need to paste it in the Listing Grid widget (open the Posts Query block and add a new item with the Posts Parameters type).

Remember that ‘post-type-slug’ in the described macro stands for the actual post type slug you want to use (e.g., “events”). It also concerns the following macros for relations described below.

%related_parents_from|post-type-slug% — this macro code is used for displaying only the parent-related posts. You need to paste it in the Listing Grid widget (head to the Posts Query block and add a new item with the Posts Parameters type).

%get_grandparent|post-type-slug% — allows setting the connection between two already existing relations. With this macro, you can display grandparent posts. 

For example, you have three post types: Countries, Continents, and Tours, and you need to create a grandparent relation between Continents and Tours. Go to the Post Query (Elementor) or Query Settings (Gutenberg) and enter the macros. Please, check the tutorial on How to Build Grandparent/Grandchild Relations to find out more. 

%get_grandchild|post-type-slug% — with this macro, you can display grandchild posts. It will work vice versa; in the Single Tour show the Continents Listing with the Listing Grid, and then we need to use %get_grandparent|from-post-type%.

Macros for Users

%author_id% — once working with the Single page, insert this macro in the Users Listing Grid in the Include Users by ID field to display the name and information of the author under the post. 

%queried_user_id% — it returns the ID of the queried user only on the Profile Builder pages and in the listing for users; in all other cases – it returns the current user ID.

%current_user_id% — returns the ID or the current user. 

%current_user_meta|field-name% — get a value from the meta field of the current user. Specify the user’s meta field by changing the ‘field-name’ into the needed meta field name, where you need to get the info from.

Macros for Data Stores

NOTE
The ‘store-slug’ part in the following macros should be replaced by the actual Slug you have selected for the JetEngine Data Store.

%get_store|store-slug% — returns IDs from the data store.

%store_count|store-slug% — returns the amount of the items in the store.

%get_users_for_store_item|store-slug|context% — works only with User store and returns IDs of users who added this post/user into their Data Stores. In other words – if you create Follow the system, with %get_store% macros, you can output users from the following list of the current user, and with %get_users_for_store_item% you can output a list of followers of the current user. To use this macro correctly, you need to pass two parameters – %get_users_for_store_item|store-slug|context% store-slug is your actual store slug, and context defines where the plugin will look for the current item ID to search it in other user stores. This parameter accepts four values:

– post — this is the default context, which will be used if the second parameter is not passed. This context means that the current post ID will be used as an item ID for search. With this context, you can, for example, output a list of users who liked/bookmarked this post;

– user — means that the current user ID will be used. With this context, you can output a list of followers for the current user;

– queried_user — means that the not current user ID but currently queried user ID will be used. With this context, you can output the list of followers of some author on the author archive template or a list of followers of users on the single user page added by JetEngine Profile Builder;

– author — means that the current post author ID will be used. You can use this context to output followers of the current post author in the author box (Context option also added for all Dynamic Widgets and User related dynamic tags, so from now on, you can build an author box with JetEngine without additional listing).

Macros for CCT

%current_field|field_key% — this is a macro for the CCT listing items. It returns the value of the specified CCT field; if no field is specified, it returns the item ID.

Macros for Repeater

The following macros can be used both in the Dynamic Repeater and the email notifications in Forms.

So, you can use them both for the Dynamic Repeater widget to display data from the Repeater fields or receive email notifications about the data user has typed in the form.

%post_id|post_title_by_id% — paste the macro into the Content field of the “Send Email” post submit action to get the page title via the email.

%name% — this macro code and HTML markup (<span></span> or <div></div>) are used to format the repeater content in the Item Format field of Dynamic Repeater widget. You need to insert the particular IDs of the meta fields included in the repeater to display the content added in the certain meta field (e.g., %text% – this is the macro that will help display the content added in the meta field called “Text).

NOTE
There is no possibility to send some Repeater fields via the form separately. Use the %name% macro to send the data input in the Repeater. However, paste the “Repeatable Fields Group Start” Type field name instead of the ‘name’.

%media-field|img_url_by_id% — insert this macro in the Item Format field of the Dynamic Repeater widget to display the image URL link that will be pulled from the database.

Mind to use the media field key instead of the ‘media-field’ value.

NOTE
As this macro works with ID, mind to choose the “Attachment ID” as the Field value option in the media field settings of the form. In this way, the macro will send the URL of the chosen image.

Or you can simply select the “Attachment URL” as the Field value and add the %name% macro.

Though, if you want the user to upload several pictures, you need to select the “Attachment URL” option in the Field value drop-down list.

%gallery-field|img_gallery_grid% — insert this macro in the Item Format field of the Dynamic Repeater widget to display the gallery in one of the repeater subfields. This macro works specifically with Dynamic Repeater.

Paste your gallery field key name instead of the “gallery-field” value.

%link|post_url_by_id% — place this macro in the Item Format field of the Dynamic Repeater widget to add the Post URL that is added with ACF to the repeater subfield.

The “link” value stands for the ACF Post URL.

%date-field|format_date% or %date-field|format_date(F j, Y)% — use those macros if you need to change the date in the Dynamic Repeater widget (the macro should be inserted in the Dynamic Field widget in the Content block on the Elementor editing page). 

The ‘date-field’ value stands for the name of the date/time/datetime field, and F j, Y is the date format, which can be changed in accordance with this tutorial.

Besides, you can insert this %date-field|format_date% macro in the Notification Settings block in the Form, and your Form’s field will inherit the default date format set in WordPress settings.

Or the macros can look like: %date-field|format_date(d)% or %time-field|format_date(h)%.

%media-field|img_alt_by_id% — displays an alternative text for an image.

%media-field|file_url_by_id% — with this macro, you can get the link for the attachment.

%post-field|post_title_by_id% — allows getting the name of the post.

%post-field|post_titles_by_ids% — add this macro to get the name of posts. It will take data from the field that has several posts.

%post-field|post_link_by_id% — you can add this macro to the Dynamic Field to get the link of the post. 

NOTE
‘media-field’ and ‘post-field’ mentioned earlier should be replaced by the values you want to display.

%checkbox-field|render_acf_checkbox% — insert this macro to display the value from the ACF checkbox field. Also, you can display fields from the JetEngine if the Save As Array option is enabled. 

Mind pasting the actual checkbox field value you want to display data from instead of the “checkbox-field”.

%repeater-field|embed_url% — allows you to add the URL. For example, you can display a video.

Paste the needed link to the text meta field added to the Repeater and display it by adding the mentioned macro in the Item format field. Replace the ‘repeater-field’ value with the text meta field name you have added to the Repeater.

%term-field|term_title_by_id% — add this macro if you need to display the term’s name by ID.

%term-field|term_titles_by_ids% — this macro allows to display names of terms by their IDs.

NOTE
Paste the two previous macros in the form together to send data properly, as the user can select either one or several terms.

%query_var|field-name% — use this macro if you are working with the “Redirect to Page” post submit action of the form and want to redirect users to the static page after the form submission. If you deal with the Add query arguments to the redirect URL and tick some fields in there, you may need this macro. 

Proceed to the static page you have picked in the Select page field and add a Dynamic Link widget to it. Leave the default settings, and paste the mentioned macro in the Label field. Just mind changing the ‘field-name’ into the actual name of the field you have ticked in the Add query arguments to the redirect URL.

Once the user submits the form, it will redirect the user to the page where the entered information of the used field will be displayed.

That’s it; now you know how to use JetEngine functionality to display particular data with the help of provided macros.