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, which allows calling 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 Listing Grid, Query Builder, and Dynamic Link widget. Let’s have a closer look at them.

%current_categories% – returns current post categories;
in order 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.

%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 and 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%
in case 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 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 Parameters query type of Listing Grid widget in order 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.

%field_value% – choose the needed field from the source and add this macro to the Label field in the Dynamic Link widget to get the value of the field, set to be the Source of Dynamic Link. For example, if you are using a meta field with URL as a link source, %field value% returns this link. 

%current_meta% – use this macro if you need to get the value of the field %current_meta|field_name% or you can get the value of all fields in the current post if you’ll simply add the %current_meta%. 
Also, there’s an opportunity to display posts on the Single page that should be filtered by meta field meaning. You can use the macro %current_meta|field_name%. Instead of the field_name add the name of the needed meta field. 

%current_meta_string% – 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. 

Macros for Relations

%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 (Posts Query block and here add a new item with the Posts Parameters type)

%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 (Posts Query block and here 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 display the Continents Listing with the Listing Grid, and then we need to use %get_grandparent|from-post-type%.

%related_children_between% – will return the ID of all events that are child posts of the current producer.

Note: you can display either parent or child related posts, and the “|post-type-slug” stands for the actual post type slug (e.g., “events”)

Macros for Users

%author_id% – insert this macro in the posts grid to display the name and information of the author under the post. 

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

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

Macros for Data Stores

%get_store|store% – returns IDs from the data store.

%store_count|store% – returns the amount of the items in the store.

%get_users_for_store_item|store|context% – works only with User Meta store and returns IDs of users who added this post/user into their own Data Stores. In the other words – if you creating 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 2 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 4 values:
– post – this is the default context, which will be used if 2nd 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 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. Returns the value of the specified CCT field; if no field is specified – returns item ID. Works in CCT listing items.

Macros for Repeater

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

%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, which are included in the repeater to display the content added in the certain meta field (e.g., %text% – this is the macros that will help in displaying the content added in the Text meta field).

%media1|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.

%gallery1|img_gallery_grid% – insert this macro in the Item Format field of Dynamic Repeater widget to display the gallery in one of the repeater sub fields.

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

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

%date_meta|format_date% or %date_meta|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 to the Dynamic Field widget in the Content block on the Elementor editing page). Where date_key – stands for the name of the date field in the repeater, and F j, Y – is the date format, which can be changed in accordance with this tutorial.

%img_alt_by_id% – displays an Alternative text for an image.

%file_url_by_id% – with this macro you can get the link for the attachment.

%post_title_by_id% – allows getting the name of the post.

%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_link_by_id% – you can add this macro to the Dynamic Field to get the link for the post. 

%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. 

%embed_url% – allows you to add the URL For example, you can display a video.

%term_title_by_id% – add this macro if you need to display the name of the term by ID.

%term_titles_by_ids% – this macro allows to display name of terms by their IDs.

Hope, this guide will help you to use JetEngine functionality for displaying particular data with the help of provided macros.