The Macros Generator in JetEngine allows you to leverage dynamic macros across multiple locations and options within your website. Macros can be used with widgets, forms, and dynamic content to pull data efficiently and customize how it’s displayed. This guide will outline key use cases and steps for using macros effectively.
Use Cases for Macros:
Displaying Data with the Dynamic Field Widget
If you want to display data (for example, post titles) from a query, here’s how to use macros with the Dynamic Field widget:
Create a Query: Start by creating the necessary query to pull data, such as post titles.
Generate Macros: Use the Macros Generator to generate macros for your query.
Display with Dynamic Field Widget:
Set the Source as “Meta Data” in the widget.
Leave the Meta Field empty.
Add any random letters for non-existing metafield in Custom Field.
Add Macros in Customized Field Output: Enclose your macro with
%%
, like this:%%query_results|43|selected|post_title%%
Using Macros with Widgets that Support Dynamic Tags
You can also display macros with widgets that support dynamic tags, such as the Heading widget.
Install the Addon: Download and install this addon as a plugin.
Add Macros: In the widget, select the dynamic tag option “Do Macros” to display macros content dynamically.
Sending Emails to Multiple Users with Forms
If you want to send emails to multiple users registered on your website, follow these steps:
Create a Query: Start by creating a query to target registered users.
Generate Macros: Use the Macros Generator to create a macro for fetching user data from the query.
Add Code: Place the following code in your functions.php file (for your child theme) or in the Code Snippets plugin
Use Macros in Forms: Insert the macro in the Manual Input of a Hidden field. This data can now be used in the Send Email action.
Creating an Author Archive (Static Page for User Posts)
To set up a static page displaying posts from a specific user (e.g., by clicking on their profile in a listing grid):
Step 1: Create a User Listing Page
Use the Dynamic Link widget within the listing.
Leave the Source field unselected and use any placeholder in the Meta Field.
Add the URL Prefix as the link to the page where you want to list the posts.
Include a Query Argument with
user_id=%queried_user_id%
.%queried_user_id%
is a macro generated using the Macros Generator.
Step 2: Set Up the Destination Page (User Posts)
Create a second page with a listing for posts.
Configure it to filter posts by the clicked user from the previous page.
When a user clicks on the link in the listing grid, they will be redirected to a page displaying posts from that specific user only.
This guide covers the essential use cases for the Macros Generator in JetEngine, providing flexibility in displaying dynamic content, configuring forms, and creating user-specific pages. With this setup, you can enhance user experience by personalizing data display and interaction.