{"id":26171,"date":"2022-01-25T09:37:14","date_gmt":"2022-01-25T09:37:14","guid":{"rendered":"https:\/\/crocoblock.com\/knowledge-base\/?post_type=article&#038;p=26171"},"modified":"2024-08-13T10:46:51","modified_gmt":"2024-08-13T10:46:51","slug":"jetengine-macros-for-wordpress-relations","status":"publish","type":"article","link":"https:\/\/crocoblock.com\/knowledge-base\/jetengine\/jetengine-macros-for-wordpress-relations\/","title":{"rendered":"Macros for WordPress Relations"},"content":{"rendered":"<div class=\"note-banner d-flex border-bold border-jetsmartfilters rounded overflow-hidden p-20\"><div class=\"mr-12\"><svg width=\"24\" height=\"24\" viewBox=\"0 0 24 24\" fill=\"none\" xmlns=\"http:\/\/www.w3.org\/2000\/svg\"><path d=\"M1 21H23L12 2L1 21ZM13 18H11V16H13V18ZM13 14H11V10H13V14Z\" fill=\"#FA5450\"\/><\/svg><\/div><div class=\"d-flex flex-column\"><div class=\"text-900 mb-12\">Warning<\/div><p class=\"m-0\">Be aware that the legacy macros work only with the legacy relations. The refactoring macros described in this tutorial work with the refactoring relation that you can create after the 2.11.0 <strong>JetEngine<\/strong> update.<\/p><\/div><\/div>\n\n\n\n<img decoding=\"async\" src=\"https:\/\/crocoblock.com\/knowledge-base\/wp-content\/uploads\/2022\/01\/legacy-and-refactoring-macros2.png\" alt=\"legacy and refactoring macros\">\n\n\n\n<h2 class=\"wp-block-heading\" id=\"related-items-macro\"><strong>Related Items Macro<\/strong><\/h2>\n\n\n\n<div class=\"wp-block-group is-layout-constrained wp-block-group-is-layout-constrained\"><div class=\"wp-block-group__inner-container\">\n<p> If you created a parent-child relationship and want to show related items &#8211; this macro is for you.<\/p>\n\n\n<div class=\"note-banner d-flex border-bold border-jetthemecore rounded overflow-hidden p-20\"><div class=\"mr-12\"><svg width=\"24\" height=\"24\" viewBox=\"0 0 24 24\" fill=\"none\" xmlns=\"http:\/\/www.w3.org\/2000\/svg\"><path d=\"M9 21C9 21.5 9.4 22 10 22H14C14.6 22 15 21.5 15 21V20H9V21ZM12 2C8.1 2 5 5.1 5 9C5 11.4 6.2 13.5 8 14.7V17C8 17.5 8.4 18 9 18H15C15.6 18 16 17.5 16 17V14.7C17.8 13.4 19 11.3 19 9C19 5.1 15.9 2 12 2Z\" fill=\"#F2D23C\"\/><\/svg><\/div><div class=\"d-flex flex-column\"><div class=\"text-900 mb-12\">Things to know<\/div><p class=\"m-0\">This macro displays parent or children items of the object.<\/p><\/div><\/div>\n\n\n\n<p>This macro allows you to get children or parent posts related to the object. For example, if you have the <strong>Providers <\/strong>and <strong>Services <\/strong>related post types, you can display only those services that the particular provider offers.<\/p>\n\n\n\n<img decoding=\"async\" src=\"https:\/\/crocoblock.com\/knowledge-base\/wp-content\/uploads\/2022\/01\/related-post-types-2.png\" alt=\"related parent post and children posts\">\n\n\n\n<p>Navigate to <strong><em>JetEngine &gt; Query Builder<\/em>, <\/strong>and hit the <strong>\u201cAdd New\u201d<\/strong> button.<\/p>\n\n\n\n<p>Give your query a <strong>Name<\/strong>. Select the type of parent or children items you want to display in the <strong>Query Type<\/strong> field. For example, if you need to get the child posts of the parent user, choose the \u201cPost Query\u201d option.<\/p>\n\n\n\n<h3 class=\"wp-block-heading\" id=\"posts-query\">Posts Query<\/h3>\n\n\n\n<p>If you need to get the related items from the post type, select the \u201cPost Query\u201d option in the <strong>Query Type<\/strong> field. In the <strong>General<\/strong> section, specify the <strong>Post Type<\/strong>.<\/p>\n\n\n\n<img decoding=\"async\" src=\"https:\/\/crocoblock.com\/knowledge-base\/wp-content\/uploads\/2022\/01\/Post-Query-type-for-the-related-items-2.png\" alt=\"posts query type for the related items\">\n\n\n\n<p>Open the <strong>Post &amp; Page<\/strong> section, click on the macros icon near the <strong>Post In<\/strong> field and select the \u201cRelated Items\u201d option.<\/p>\n\n\n\n<img decoding=\"async\" src=\"https:\/\/crocoblock.com\/knowledge-base\/wp-content\/uploads\/2022\/01\/macros-in-query-2.png\" alt=\"macros in query\">\n\n\n\n<p>There are such settings in the <strong>Related Items <\/strong>window:<\/p>\n\n\n\n<ul>\n<li><strong>From Relation<\/strong>. Specify the relation from where you want to get parent or children items;<\/li>\n\n\n\n<li><strong>From Object<\/strong>. Specify if you want to display children (<strong>Child Object<\/strong> option) or parent (<strong>Parent Object<\/strong> option) items;<\/li>\n\n\n\n<li><strong>Initial Object ID From<\/strong>. Indicate where the query will get the object ID from to display its related items:\n<ul>\n<li><strong>Current Object ID<\/strong>. Shows the related items of the current post on the Single Page (as in our example, the query shows the related services of the current provider post), of the current active listing item, and so on;<\/li>\n\n\n\n<li><strong>Current User ID.<\/strong> Shows the related items of the currently logged-in user;<\/li>\n\n\n\n<li><strong>Queried User ID.<\/strong> Shows the related items of the selected user, e.g., on the User Page in the <a href=\"https:\/\/crocoblock.com\/knowledge-base\/articles\/jetengine-user-profile-builder-overview\/\" target=\"_blank\" rel=\"noreferrer noopener\"><strong>Profile Builder<\/strong><\/a>;<\/li>\n\n\n\n<li><strong>Query Variable<\/strong>. Shows the related items from the global request or WordPress request variables. If you select this option, the fourth <strong>Variable Name <\/strong>will appear;<\/li>\n\n\n\n<li><strong>Current Object Variable<\/strong>. Shows the related items from the object defined as current by JetEngine<strong>. <\/strong>If you select this option, the fourth <strong>Variable Name <\/strong>will<strong> <\/strong>appear;<\/li>\n\n\n\n<li><strong>Default WordPress Object (for current page)<\/strong>. Always shows the related items of a current global object for the current page defined by WordPress, as opposed to the \u201cFrom Relation\u201d option. For instance, on a single page\/single post, it will always be the current post, even if you go to the listing added to this page.<\/li>\n<\/ul>\n<\/li>\n\n\n\n<li><strong>Variable Name<\/strong>. This field appears if you select the \u201cQuery Variable\u201d or \u201cCurrent Object Variable\u201d options. This option allows setting the variable&#8217;s name, which the plugin will search for in the query or current object.<\/li>\n<\/ul>\n\n\n\n<img decoding=\"async\" src=\"https:\/\/crocoblock.com\/knowledge-base\/wp-content\/uploads\/2022\/01\/related-items-macro-2.png\" alt=\"related items macros\">\n\n\n\n<p>We have set such a query for the relation in this tutorial. After you finish, click on the <strong>\u201cApply\u201d<\/strong> and <strong>\u201cAdd Query\u201d<\/strong> buttons.<\/p>\n\n\n\n<img decoding=\"async\" src=\"https:\/\/crocoblock.com\/knowledge-base\/wp-content\/uploads\/2022\/01\/query-for-the-related-post-types-2.png\" alt=\"query for related post types\">\n\n\n\n<p>Create a <a href=\"https:\/\/crocoblock.com\/knowledge-base\/features\/listing-template-in-elementor-overview\/\" target=\"_blank\" rel=\"noreferrer noopener\"><strong>Listing<\/strong> <strong>Item<\/strong><\/a> for the related children\/parent post you want to display if you haven\u2019t done it yet. Then fill it with content using, for example, <a href=\"https:\/\/crocoblock.com\/knowledge-base\/articles\/jetengine-dynamic-field-widget-overview-how-to-use-filter-field-output\/\" target=\"_blank\" rel=\"noreferrer noopener\"><strong>Dynamic Field<\/strong><\/a> or other dynamic widgets. Don\u2019t forget to publish it.<\/p>\n\n\n\n<img decoding=\"async\" src=\"https:\/\/crocoblock.com\/knowledge-base\/wp-content\/uploads\/2022\/01\/setup-listing-item-2.png\" alt=\"setup listing item for posts\">\n\n\n\n<p>Proceed to the <a href=\"https:\/\/crocoblock.com\/knowledge-base\/articles\/creating-custom-post-type-archive-template-with-jetengine-listing-grid\/\" target=\"_blank\" rel=\"noreferrer noopener\"><strong>Single Page<\/strong><\/a> (or the <strong>Archive Page <\/strong>for the related terms) with parent\/child item (e.g., post) and place the <strong>Listing Grid<\/strong> with the children\/parent items there. Open the <strong>Custom Query<\/strong> section in the <strong>Listing Grid<\/strong> widget, enable the <strong>Use Custom Query<\/strong> toggle, and select the name of the needed <strong>Custom Query<\/strong>. After you finish editing, hit the <strong>\u201cPublish\u201d<\/strong> or <strong>\u201cUpdate\u201d <\/strong>button.<\/p>\n\n\n\n<img decoding=\"async\" src=\"https:\/\/crocoblock.com\/knowledge-base\/wp-content\/uploads\/2022\/01\/listing-grid-custom-query-2.png\" alt=\"listing grid custom query\">\n\n\n\n<h3 class=\"wp-block-heading\" id=\"terms-query\">Terms Query<\/h3>\n\n\n\n<p>Select the \u201cTerms Query\u201d option in the <strong>Query Type<\/strong> field to get the related items from the taxonomy. In the <strong>General<\/strong> section, choose the <strong>Taxonomy<\/strong> name or several names.<\/p>\n\n\n\n<img decoding=\"async\" src=\"https:\/\/crocoblock.com\/knowledge-base\/wp-content\/uploads\/2022\/01\/terms-query-type-2.png\" alt=\"terms query type\">\n\n\n\n<p>Open the <strong>Include\/Exclude<\/strong> section, hit the macros icon near the <strong>Include<\/strong> field, and select the \u201cRelated Items\u201d option. Then, set the macro options according to your needs. We have described all macro settings in the <strong>Posts Query <\/strong>paragraph.<\/p>\n\n\n\n<img decoding=\"async\" src=\"https:\/\/crocoblock.com\/knowledge-base\/wp-content\/uploads\/2022\/01\/related-items-macro-for-terms-2.png\" alt=\"related items macro for terms\">\n\n\n\n<p>After you finish, click on the <strong>\u201cApply\u201d<\/strong> and <strong>\u201cAdd Query\u201d<\/strong> buttons.<\/p>\n\n\n\n<p>Create a <a href=\"https:\/\/crocoblock.com\/knowledge-base\/features\/listing-template-in-elementor-overview\/\" target=\"_blank\" rel=\"noreferrer noopener\"><strong>Listing<\/strong> <strong>Item<\/strong><\/a> for the related children\/parent terms you want to display if you haven\u2019t done it yet.<\/p>\n\n\n\n<img decoding=\"async\" src=\"https:\/\/crocoblock.com\/knowledge-base\/wp-content\/uploads\/2022\/01\/setup-listing-item-for-terms-2.png\" alt=\"setup listing item for terms\">\n\n\n\n<p>Fill it with content with the help of, for example, <a href=\"https:\/\/crocoblock.com\/knowledge-base\/articles\/jetengine-dynamic-field-widget-overview-how-to-use-filter-field-output\/\" target=\"_blank\" rel=\"noreferrer noopener\"><strong>Dynamic Field<\/strong><\/a> or other dynamic widgets.<\/p>\n\n\n\n<img decoding=\"async\" src=\"https:\/\/crocoblock.com\/knowledge-base\/wp-content\/uploads\/2022\/01\/listing-item-with-the-dynamic-field-2.png\" alt=\"listing item for terms with the dynamic field\">\n\n\n\n<p>Proceed to the <a href=\"https:\/\/crocoblock.com\/knowledge-base\/articles\/creating-custom-post-type-archive-template-with-jetengine-listing-grid\/\" target=\"_blank\" rel=\"noreferrer noopener\"><strong>Single Page<\/strong><\/a> (or the <strong>Archive Page <\/strong>for the related terms) with parent\/child item (e.g., post) and place the <strong>Listing Grid<\/strong> with the children\/parent items there. Open the <strong>Custom Query<\/strong> section in the <strong>Listing Grid<\/strong> widget, enable the <strong>Use Custom Query<\/strong> toggle and select the name of the needed <strong>Custom Query<\/strong>. After you finish editing, hit the <strong>\u201cPublish\u201d<\/strong> or <strong>\u201cUpdate\u201d <\/strong>button. Then, you can navigate to the front end and look at the result.<\/p>\n\n\n\n<img decoding=\"async\" src=\"https:\/\/crocoblock.com\/knowledge-base\/wp-content\/uploads\/2022\/01\/related-terms-on-the-single-page-2.png\" alt=\"related terms on the single page\">\n\n\n\n<h3 class=\"wp-block-heading\" id=\"users-query\">Users Query<\/h3>\n\n\n\n<p>Select the \u201cUsers Query\u201d <strong>Type <\/strong>if you decide to display related users. Proceed to the <strong>Include\/Exclude <\/strong>section, hit the macros icon near the <strong>Include<\/strong> field, and select the \u201cRelated Items\u201d option. Then, set the macro options according to your needs. After you finish, click on the <strong>\u201cApply\u201d<\/strong> and <strong>\u201cAdd Query\u201d<\/strong> buttons.<\/p>\n\n\n\n<img decoding=\"async\" src=\"https:\/\/crocoblock.com\/knowledge-base\/wp-content\/uploads\/2022\/01\/users-query-type-for-relations-2.png\" alt=\"users query type for relations\">\n\n\n\n<p>Then, create a <strong>Listing Item<\/strong> for users and drag-and-drop the <strong>Listing Grid <\/strong>widget on the <strong>Single Page <\/strong>(or you can place it on the <strong>Archive Page <\/strong>for the related terms). Open the <strong>Custom Query<\/strong> section in the <strong>Listing Grid<\/strong> widget, enable the <strong>Use Custom Query<\/strong> toggle, and select the name of the needed <strong>Custom Query<\/strong>. After you finish editing, hit the <strong>\u201cPublish\u201d<\/strong> or <strong>\u201cUpdate\u201d <\/strong>button. Then, you can navigate to the front end and look at the result.<\/p>\n\n\n\n<img decoding=\"async\" src=\"https:\/\/crocoblock.com\/knowledge-base\/wp-content\/uploads\/2022\/01\/related-users-on-the-single-page-2.png\" alt=\"related users on the front end\">\n\n\n\n<h3 class=\"wp-block-heading\" id=\"custom-content-type-query\">Custom Content Type Query<\/h3>\n\n\n\n<p>If you decide to display <a href=\"https:\/\/crocoblock.com\/knowledge-base\/articles\/jetengine-related-custom-content-type-items\/\" target=\"_blank\" rel=\"noreferrer noopener\"><strong>related Custom Content Type items<\/strong><\/a>, select the \u201cCustom Content Type Query\u201d <strong>Type<\/strong> and select the name of the needed CCT in the <strong>From Content Type <\/strong>field.<\/p>\n\n\n\n<div class=\"wp-block-image size-large\"><a href=\"https:\/\/crocoblock.com\/knowledge-base\/wp-content\/uploads\/2022\/01\/custom-content-type-query-for-relations.webp\"><img loading=\"lazy\" decoding=\"async\" width=\"1824\" height=\"1100\" src=\"https:\/\/crocoblock.com\/knowledge-base\/wp-content\/uploads\/2022\/01\/custom-content-type-query-for-relations.webp\" alt=\"custom content type query for relations\" class=\"wp-image-45315\" srcset=\"https:\/\/crocoblock.com\/knowledge-base\/wp-content\/uploads\/2022\/01\/custom-content-type-query-for-relations.webp 1824w, https:\/\/crocoblock.com\/knowledge-base\/wp-content\/uploads\/2022\/01\/custom-content-type-query-for-relations-300x181.webp 300w, https:\/\/crocoblock.com\/knowledge-base\/wp-content\/uploads\/2022\/01\/custom-content-type-query-for-relations-1024x618.webp 1024w, https:\/\/crocoblock.com\/knowledge-base\/wp-content\/uploads\/2022\/01\/custom-content-type-query-for-relations-768x463.webp 768w, https:\/\/crocoblock.com\/knowledge-base\/wp-content\/uploads\/2022\/01\/custom-content-type-query-for-relations-1536x926.webp 1536w, https:\/\/crocoblock.com\/knowledge-base\/wp-content\/uploads\/2022\/01\/custom-content-type-query-for-relations-600x362.webp 600w\" sizes=\"(max-width: 1824px) 100vw, 1824px\" \/><\/a><\/div>\n\n\n\n<p>Hit the <strong>\u201cAdd new\u201d <\/strong>button in the <strong>Query <\/strong>section. In the repeater field, pick the \u201cItem ID\u201d option for the <strong>Field <\/strong>and the<strong> <\/strong>\u201cIn the list\u201d for the <strong>Compare. <\/strong>Hit the &#8220;<strong>coin stack<\/strong>&#8221; icon near the <strong>Value<\/strong> field, and select the \u201cRelated Items\u201d option. Then, set the macro options according to your needs. At last, select the \u201cNumeric\u201d <strong>Type. <\/strong>After you finish, click the <strong>\u201cApply\u201d<\/strong> button. To save the query settings, hit the &#8220;<strong>Add\/Update Query<\/strong>.&#8221;<\/p>\n\n\n\n<div class=\"wp-block-image size-large\"><a href=\"https:\/\/crocoblock.com\/knowledge-base\/wp-content\/uploads\/2022\/01\/query-CCT-settings-with-the-related-items-macro.webp\"><img loading=\"lazy\" decoding=\"async\" width=\"1824\" height=\"1100\" src=\"https:\/\/crocoblock.com\/knowledge-base\/wp-content\/uploads\/2022\/01\/query-CCT-settings-with-the-related-items-macro.webp\" alt=\"\" class=\"wp-image-45316\" srcset=\"https:\/\/crocoblock.com\/knowledge-base\/wp-content\/uploads\/2022\/01\/query-CCT-settings-with-the-related-items-macro.webp 1824w, https:\/\/crocoblock.com\/knowledge-base\/wp-content\/uploads\/2022\/01\/query-CCT-settings-with-the-related-items-macro-300x181.webp 300w, https:\/\/crocoblock.com\/knowledge-base\/wp-content\/uploads\/2022\/01\/query-CCT-settings-with-the-related-items-macro-1024x618.webp 1024w, https:\/\/crocoblock.com\/knowledge-base\/wp-content\/uploads\/2022\/01\/query-CCT-settings-with-the-related-items-macro-768x463.webp 768w, https:\/\/crocoblock.com\/knowledge-base\/wp-content\/uploads\/2022\/01\/query-CCT-settings-with-the-related-items-macro-1536x926.webp 1536w, https:\/\/crocoblock.com\/knowledge-base\/wp-content\/uploads\/2022\/01\/query-CCT-settings-with-the-related-items-macro-600x362.webp 600w\" sizes=\"(max-width: 1824px) 100vw, 1824px\" \/><\/a><\/div>\n<\/div><\/div>\n\n\n\n<h2 class=\"wp-block-heading\" id=\"related-siblings-macro\"><strong>Related Siblings Macro<\/strong><\/h2>\n\n\n\n<div class=\"wp-block-group is-layout-constrained wp-block-group-is-layout-constrained\"><div class=\"wp-block-group__inner-container\">\n<p>The <strong>Related Siblings Macro<\/strong> is similar to the <strong>Related Item Macro<\/strong>, but it displays siblings. For example, you have the \u201cCountry > Tours\u201d connection. The <strong>Related Item Macro <\/strong>can show the children tours of the country in the <strong>Listing Grid <\/strong>on the Country Single Page, and the <strong>Related Siblings Macro <\/strong>can display the related tours on the Tour Single Page.<\/p>\n\n\n\n<p>Go to <strong><em>WordPress Dashboard > JetEngine > Query Builder<\/em>, <\/strong>and hit the <strong>\u201cAdd New\u201d<\/strong> button.<\/p>\n\n\n\n<p>Give your query a <strong>Name<\/strong>. Select the type of sibling items you want to display in the <strong>Query Type<\/strong> field (e.g., &#8220;Posts Query&#8221; for posts).<\/p>\n\n\n\n<p>In the <strong>General<\/strong> section, specify the <strong>Post Type<\/strong>.<\/p>\n\n\n\n<div class=\"wp-block-image size-large\"><a href=\"https:\/\/crocoblock.com\/knowledge-base\/wp-content\/uploads\/2022\/01\/query-for-related-siblings.webp\"><img loading=\"lazy\" decoding=\"async\" width=\"1824\" height=\"1100\" src=\"https:\/\/crocoblock.com\/knowledge-base\/wp-content\/uploads\/2022\/01\/query-for-related-siblings.webp\" alt=\"query for related siblings\" class=\"wp-image-45318\" srcset=\"https:\/\/crocoblock.com\/knowledge-base\/wp-content\/uploads\/2022\/01\/query-for-related-siblings.webp 1824w, https:\/\/crocoblock.com\/knowledge-base\/wp-content\/uploads\/2022\/01\/query-for-related-siblings-300x181.webp 300w, https:\/\/crocoblock.com\/knowledge-base\/wp-content\/uploads\/2022\/01\/query-for-related-siblings-1024x618.webp 1024w, https:\/\/crocoblock.com\/knowledge-base\/wp-content\/uploads\/2022\/01\/query-for-related-siblings-768x463.webp 768w, https:\/\/crocoblock.com\/knowledge-base\/wp-content\/uploads\/2022\/01\/query-for-related-siblings-1536x926.webp 1536w, https:\/\/crocoblock.com\/knowledge-base\/wp-content\/uploads\/2022\/01\/query-for-related-siblings-600x362.webp 600w\" sizes=\"(max-width: 1824px) 100vw, 1824px\" \/><\/a><\/div>\n\n\n\n<p>Then, we open the <strong>Post &amp; Page<\/strong> section, click the &#8220;<strong>coin stack<\/strong>&#8221; icon near the <strong>Post In<\/strong> field, and select the \u201cRelated Siblings\u201d option.<\/p>\n\n\n\n<div class=\"wp-block-image size-large\"><a href=\"https:\/\/crocoblock.com\/knowledge-base\/wp-content\/uploads\/2022\/01\/related-siblings-macro.webp\"><img loading=\"lazy\" decoding=\"async\" width=\"1824\" height=\"1100\" src=\"https:\/\/crocoblock.com\/knowledge-base\/wp-content\/uploads\/2022\/01\/related-siblings-macro.webp\" alt=\"related siblings macro\" class=\"wp-image-45320\" srcset=\"https:\/\/crocoblock.com\/knowledge-base\/wp-content\/uploads\/2022\/01\/related-siblings-macro.webp 1824w, https:\/\/crocoblock.com\/knowledge-base\/wp-content\/uploads\/2022\/01\/related-siblings-macro-300x181.webp 300w, https:\/\/crocoblock.com\/knowledge-base\/wp-content\/uploads\/2022\/01\/related-siblings-macro-1024x618.webp 1024w, https:\/\/crocoblock.com\/knowledge-base\/wp-content\/uploads\/2022\/01\/related-siblings-macro-768x463.webp 768w, https:\/\/crocoblock.com\/knowledge-base\/wp-content\/uploads\/2022\/01\/related-siblings-macro-1536x926.webp 1536w, https:\/\/crocoblock.com\/knowledge-base\/wp-content\/uploads\/2022\/01\/related-siblings-macro-600x362.webp 600w\" sizes=\"(max-width: 1824px) 100vw, 1824px\" \/><\/a><\/div>\n\n\n\n<p>Then, set the macro options as per your needs. The settings of this macro are similar to the previous one. For our cause, we select the name of the needed relation in the <strong>From Relation <\/strong>field, the \u201cChild Object\u201d option (because we want to display tours that are children items in our relation), and the \u201cCurrent Object ID\u201d option (because we wish that users see the related tours of the tour which post they visit), and push the &#8220;<strong>Apply<\/strong>&#8221; button.<\/p>\n\n\n\n<div class=\"wp-block-image size-large\"><a href=\"https:\/\/crocoblock.com\/knowledge-base\/wp-content\/uploads\/2022\/01\/related-siblings-macro-for-the-post-types.webp\"><img loading=\"lazy\" decoding=\"async\" width=\"1824\" height=\"1100\" src=\"https:\/\/crocoblock.com\/knowledge-base\/wp-content\/uploads\/2022\/01\/related-siblings-macro-for-the-post-types.webp\" alt=\"related siblings macro for the post types\" class=\"wp-image-45322\" srcset=\"https:\/\/crocoblock.com\/knowledge-base\/wp-content\/uploads\/2022\/01\/related-siblings-macro-for-the-post-types.webp 1824w, https:\/\/crocoblock.com\/knowledge-base\/wp-content\/uploads\/2022\/01\/related-siblings-macro-for-the-post-types-300x181.webp 300w, https:\/\/crocoblock.com\/knowledge-base\/wp-content\/uploads\/2022\/01\/related-siblings-macro-for-the-post-types-1024x618.webp 1024w, https:\/\/crocoblock.com\/knowledge-base\/wp-content\/uploads\/2022\/01\/related-siblings-macro-for-the-post-types-768x463.webp 768w, https:\/\/crocoblock.com\/knowledge-base\/wp-content\/uploads\/2022\/01\/related-siblings-macro-for-the-post-types-1536x926.webp 1536w, https:\/\/crocoblock.com\/knowledge-base\/wp-content\/uploads\/2022\/01\/related-siblings-macro-for-the-post-types-600x362.webp 600w\" sizes=\"(max-width: 1824px) 100vw, 1824px\" \/><\/a><\/div>\n\n\n\n<p>Click the <strong>\u201cAdd Query\u201d<\/strong> or <strong>\u201cUpdate Query\u201d<\/strong> button. Then, create the <a href=\"https:\/\/crocoblock.com\/knowledge-base\/features\/listing-template-in-elementor-overview\/\" target=\"_blank\" rel=\"noreferrer noopener\"><strong>Listing<\/strong> <strong>Item<\/strong><\/a> if you haven\u2019t done it yet, or proceed to the <strong>Single Page<\/strong>.<\/p>\n\n\n\n<img decoding=\"async\" src=\"https:\/\/crocoblock.com\/knowledge-base\/wp-content\/uploads\/2022\/01\/tour-single-page-2.png\" alt=\"single page for tours\">\n\n\n\n<p>Place the <strong>Listing Grid<\/strong> widget there, open the <strong>Custom Query<\/strong> section, enable the <strong>Use Custom Query<\/strong> toggle, and select the name of the needed <strong>Custom Query<\/strong>. As you can see, the tour on the <strong>Single Page <\/strong>is for Argentina, so the <strong>Listing Grid <\/strong>with the query also shows the related tours for Argentina, their same parent.<\/p>\n\n\n\n<img decoding=\"async\" src=\"https:\/\/crocoblock.com\/knowledge-base\/wp-content\/uploads\/2022\/01\/listing-grid-for-the-related-siblings-2.png\" alt=\"listing grid for the related siblings\">\n\n\n\n<p>After you finish editing, hit the <strong>\u201cPublish\u201d<\/strong> or <strong>\u201cUpdate\u201d <\/strong>button.<\/p>\n<\/div><\/div>\n\n\n\n<h2 class=\"wp-block-heading\" id=\"related-grandparents-macro\"><strong>Related Grandparents Macro<\/strong><\/h2>\n\n\n\n<div class=\"wp-block-group is-layout-constrained wp-block-group-is-layout-constrained\"><div class=\"wp-block-group__inner-container\">\n<p>This macro gets the grandparents from the object. Before setting the query, be aware that you build a relationship with the <strong>Parent relation <\/strong>option enabled.<\/p>\n\n\n\n<img decoding=\"async\" src=\"https:\/\/crocoblock.com\/knowledge-base\/wp-content\/uploads\/2022\/01\/parent-relation-2.png\" alt=\"parent relation\">\n\n\n\n<p>It means that you have 2 relations, one is a \u201cParent,\u201d another one is a \u201cChild.\u201d For example, Continents to Countries and Countries to Tours. The second one should have the <strong>Parent relation<\/strong> option enabled.<\/p>\n\n\n\n<img decoding=\"async\" src=\"https:\/\/crocoblock.com\/knowledge-base\/wp-content\/uploads\/2023\/06\/Relationships-2x.png\" alt=\"relationships scheme\">\n\n\n\n<p>Now, it\u2019s time to build a query that will join those two and let us retrieve grandparents via grandchildren and vice versa.<\/p>\n\n\n\n<p>Go to <strong><em>JetEngine &gt; Query Builder<\/em>, <\/strong>and hit the <strong>\u201cAdd New\u201d<\/strong> button.<\/p>\n\n\n\n<p>Give your query a <strong>Name<\/strong>. Select the type of grandparent items you want to display in the <strong>Query Type<\/strong> field. Above, we have described how to set the different query types. For our example, we have selected the \u201cPost Query\u201d option.<\/p>\n\n\n\n<p>Click on the macros icon near the needed field and select the \u201cRelated Grandparents\u201d option.<\/p>\n\n\n\n<img decoding=\"async\" src=\"https:\/\/crocoblock.com\/knowledge-base\/wp-content\/uploads\/2022\/01\/related-grandparents-macro-2.png\" alt=\"related grandparents macro\">\n\n\n\n<p>Then, set the macro options as per your needs. For our case, we have selected the name of the relationship where a grandchild to the \u201cContinent &gt; Country\u201d relation is (&#8220;Continent&#8221; is a grandparent post type), and the \u201cCurrent Object ID\u201d option (because we want to display the continent that is a grandparent to the grandchild tour on the Single Page of the tour). If you want to know more about the <strong>Grandchild Object ID From <\/strong>options, proceed to the <strong>Related Items Macro <\/strong>section in this tutorial and read about the <strong>Initial Object ID From <\/strong>option; they have the same settings.<\/p>\n\n\n\n<img decoding=\"async\" src=\"https:\/\/crocoblock.com\/knowledge-base\/wp-content\/uploads\/2022\/01\/related-grandparents-macro-settings-2.png\" alt=\"related grandparents macro settings\">\n\n\n\n<p>Click on the <strong>\u201cAdd Query\u201d<\/strong> or <strong>\u201cUpdate Query\u201d<\/strong> button. Then, create the <a href=\"https:\/\/crocoblock.com\/knowledge-base\/features\/listing-template-in-elementor-overview\/\" target=\"_blank\" rel=\"noreferrer noopener\"><strong>Listing<\/strong><\/a> for the grandparent items if you haven\u2019t done it yet, and proceed to the grandchild <strong>Single Page<\/strong>.<\/p>\n\n\n\n<img decoding=\"async\" src=\"https:\/\/crocoblock.com\/knowledge-base\/wp-content\/uploads\/2022\/01\/tour-single-page-2.png\" alt=\"single page for tours\">\n\n\n\n<p>Place the <strong>Listing Grid<\/strong> widget with the grandparent items there. Open the <strong>Custom Query<\/strong> section in the <strong>Listing Grid<\/strong> widget, enable the <strong>Use Custom Query<\/strong> toggle, and select the name of the needed <strong>Custom Query<\/strong>. As you can see, this widget with query shows the grandparent continent of the grandchildren tour.<\/p>\n\n\n\n<img decoding=\"async\" src=\"https:\/\/crocoblock.com\/knowledge-base\/wp-content\/uploads\/2022\/01\/grandchild-and-grandparent-posts-2.png\" alt=\"grandchild and grandparent posts\">\n\n\n\n<p>After you finish editing, hit the <strong>\u201cPublish\u201d<\/strong> or <strong>\u201cUpdate\u201d <\/strong>button.<\/p>\n<\/div><\/div>\n\n\n\n<h2 class=\"wp-block-heading\" id=\"related-grandchildren-macro\">Related Grandchildren Macro<\/h2>\n\n\n\n<div class=\"wp-block-group is-layout-constrained wp-block-group-is-layout-constrained\"><div class=\"wp-block-group__inner-container\">\n<p>This macro gets the grandchildren from the related object. Before setting the query, be aware that you build a relationship with the&nbsp;<strong>Parent relation&nbsp;<\/strong>option enabled.<\/p>\n\n\n\n<img decoding=\"async\" src=\"https:\/\/crocoblock.com\/knowledge-base\/wp-content\/uploads\/2022\/01\/parent-relation-2.png\" alt=\"parent relation\">\n\n\n\n<p>It means that you have 2 relations, one is a \u201cParent,\u201d another one is a \u201cChild.\u201d For example, Continents to Countries and Countries to Tours. The second one should have the <strong>Parent relation<\/strong> option enabled.<\/p>\n\n\n\n<img decoding=\"async\" src=\"https:\/\/crocoblock.com\/knowledge-base\/wp-content\/uploads\/2023\/06\/Relationships-2x.png\" alt=\"relationships scheme\">\n\n\n\n<p>Now, it\u2019s time to build a query that will join those two and let us retrieve grandchildren via grandparents and vice versa.<\/p>\n\n\n\n<p>Go to&nbsp;<strong><em>JetEngine &gt; Query Builder<\/em>,&nbsp;<\/strong>and hit the&nbsp;<strong>\u201cAdd New\u201d<\/strong>&nbsp;button.<\/p>\n\n\n\n<p>Give your query a&nbsp;<strong>Name<\/strong>. Select the type of grandchildren items you want to display in the&nbsp;<strong>Query Type<\/strong>&nbsp;field. Above, we have described how to set the different query types. For our example, we have selected the \u201cPost Query\u201d option.<\/p>\n\n\n\n<p>Click on the macros icon near the needed field and select the \u201cRelated Grandchildren\u201d option.<\/p>\n\n\n\n<img decoding=\"async\" src=\"https:\/\/crocoblock.com\/knowledge-base\/wp-content\/uploads\/2022\/01\/related-grandchildren-macro-2.png\" alt=\"related grandchildren macro\">\n\n\n\n<p>Then, set the macro options as per your needs. For our case, we have selected the name of the relationship where a grandchild to the \u201cCountry &gt; Tours\u201d relation is (&#8220;Tours&#8221; is a grandchild post type) and the \u201cCurrent Object ID\u201d option  (because we want to display the tours that are grandchildren to the grandparent continent on the Single Page of the continent).<\/p>\n\n\n\n<img decoding=\"async\" src=\"https:\/\/crocoblock.com\/knowledge-base\/wp-content\/uploads\/2022\/01\/related-grandchildren-macro-settings-2.png\" alt=\"related children macros settings\">\n\n\n\n<p>Click on the&nbsp;<strong>\u201cAdd Query\u201d<\/strong>&nbsp;or&nbsp;<strong>\u201cUpdate Query\u201d<\/strong>&nbsp;button. Then, create the&nbsp;<a href=\"https:\/\/crocoblock.com\/knowledge-base\/features\/listing-template-in-elementor-overview\/\" target=\"_blank\" rel=\"noreferrer noopener\"><strong>Listing<\/strong><\/a>&nbsp;for the grandchildren items if you haven\u2019t done it yet, and proceed to the grandparent&nbsp;<strong>Single Page<\/strong>.<\/p>\n\n\n\n<p>Place the&nbsp;<strong>Listing Grid<\/strong>&nbsp;widget with the grandchildren items there. Open the&nbsp;<strong>Custom Query<\/strong>&nbsp;section in the&nbsp;<strong>Listing Grid<\/strong>&nbsp;widget, enable the&nbsp;<strong>Use Custom Query<\/strong>&nbsp;toggle, and select the name of the needed&nbsp;<strong>Custom Query<\/strong>.<\/p>\n\n\n\n<img decoding=\"async\" src=\"https:\/\/crocoblock.com\/knowledge-base\/wp-content\/uploads\/2022\/01\/custom-query-in-the-listing-grid-2.png\" alt=\"custom query for the listing grid\">\n\n\n\n<p>As you can see, this widget with query shows the grandchildren tours of the Europe grandparent continent.<\/p>\n\n\n\n<img decoding=\"async\" src=\"https:\/\/crocoblock.com\/knowledge-base\/wp-content\/uploads\/2022\/01\/grandparent-and-grandchildren-posts-on-the-front-end-2.png\" alt=\"grandparent and grandchildren posts on the front end\">\n<\/div><\/div>\n\n\n\n<p>That\u2019s it. Now you know how to display the WordPress related parent, children, sibling, and grandparent posts, terms, users, and CCT items with the help of macros and the <strong>JetEngine Query Builder<\/strong> feature.<\/p>\n","protected":false},"excerpt":{"rendered":"<p>This tutorial describes how to display the related parent, children, sibling, grandparent, and grandchildren posts, terms, users, and CCT items with the help of the WordPress JetEngine plugin.<\/p>\n","protected":false},"author":11,"featured_media":0,"template":"","format":"standard","builder-category":[],"article-category":[399],"yoast_head":"<!-- This site is optimized with the Yoast SEO plugin v20.9 - https:\/\/yoast.com\/wordpress\/plugins\/seo\/ -->\n<title>Macros for WordPress Relations \u2014 JetEngine | Crocoblock<\/title>\n<meta name=\"description\" content=\"Discover how to display the related parent, children, sibling, and grandparent posts, terms, users, and CCT items with the help of the WordPress JetEngine plugin.\" \/>\n<meta name=\"robots\" content=\"index, follow, max-snippet:-1, max-image-preview:large, max-video-preview:-1\" \/>\n<link rel=\"canonical\" href=\"https:\/\/crocoblock.com\/knowledge-base\/jetengine\/jetengine-macros-for-wordpress-relations\/\" \/>\n<meta property=\"og:locale\" content=\"en_US\" \/>\n<meta property=\"og:type\" content=\"article\" \/>\n<meta property=\"og:title\" content=\"Macros for WordPress Relations \u2014 JetEngine | Crocoblock\" \/>\n<meta property=\"og:description\" content=\"Discover how to display the related parent, children, sibling, and grandparent posts, terms, users, and CCT items with the help of the WordPress JetEngine plugin.\" \/>\n<meta property=\"og:url\" content=\"https:\/\/crocoblock.com\/knowledge-base\/jetengine\/jetengine-macros-for-wordpress-relations\/\" \/>\n<meta property=\"og:site_name\" content=\"Help Center\" \/>\n<meta property=\"article:modified_time\" content=\"2024-08-13T10:46:51+00:00\" \/>\n<meta property=\"og:image\" content=\"https:\/\/crocoblock.com\/knowledge-base\/wp-content\/uploads\/2022\/01\/legacy-and-refactoring-macros2.png\" \/>\n<meta name=\"twitter:card\" content=\"summary_large_image\" \/>\n<meta name=\"twitter:label1\" content=\"Est. reading time\" \/>\n\t<meta name=\"twitter:data1\" content=\"16 minutes\" \/>\n<script type=\"application\/ld+json\" class=\"yoast-schema-graph\">{\"@context\":\"https:\/\/schema.org\",\"@graph\":[{\"@type\":\"WebPage\",\"@id\":\"https:\/\/crocoblock.com\/knowledge-base\/jetengine\/jetengine-macros-for-wordpress-relations\/\",\"url\":\"https:\/\/crocoblock.com\/knowledge-base\/jetengine\/jetengine-macros-for-wordpress-relations\/\",\"name\":\"Macros for WordPress Relations \u2014 JetEngine | Crocoblock\",\"isPartOf\":{\"@id\":\"https:\/\/crocoblock.com\/knowledge-base\/#website\"},\"datePublished\":\"2022-01-25T09:37:14+00:00\",\"dateModified\":\"2024-08-13T10:46:51+00:00\",\"description\":\"Discover how to display the related parent, children, sibling, and grandparent posts, terms, users, and CCT items with the help of the WordPress JetEngine plugin.\",\"breadcrumb\":{\"@id\":\"https:\/\/crocoblock.com\/knowledge-base\/jetengine\/jetengine-macros-for-wordpress-relations\/#breadcrumb\"},\"inLanguage\":\"en-US\",\"potentialAction\":[{\"@type\":\"ReadAction\",\"target\":[\"https:\/\/crocoblock.com\/knowledge-base\/jetengine\/jetengine-macros-for-wordpress-relations\/\"]}]},{\"@type\":\"BreadcrumbList\",\"@id\":\"https:\/\/crocoblock.com\/knowledge-base\/jetengine\/jetengine-macros-for-wordpress-relations\/#breadcrumb\",\"itemListElement\":[{\"@type\":\"ListItem\",\"position\":1,\"name\":\"Home\",\"item\":\"https:\/\/crocoblock.com\/knowledge-base\/\"},{\"@type\":\"ListItem\",\"position\":2,\"name\":\"Articles\",\"item\":\"https:\/\/crocoblock.com\/knowledge-base\/articles\/\"},{\"@type\":\"ListItem\",\"position\":3,\"name\":\"Macros for WordPress Relations\"}]},{\"@type\":\"WebSite\",\"@id\":\"https:\/\/crocoblock.com\/knowledge-base\/#website\",\"url\":\"https:\/\/crocoblock.com\/knowledge-base\/\",\"name\":\"Help Center\",\"description\":\"\",\"publisher\":{\"@id\":\"https:\/\/crocoblock.com\/knowledge-base\/#organization\"},\"potentialAction\":[{\"@type\":\"SearchAction\",\"target\":{\"@type\":\"EntryPoint\",\"urlTemplate\":\"https:\/\/crocoblock.com\/knowledge-base\/?s={search_term_string}\"},\"query-input\":\"required name=search_term_string\"}],\"inLanguage\":\"en-US\"},{\"@type\":\"Organization\",\"@id\":\"https:\/\/crocoblock.com\/knowledge-base\/#organization\",\"name\":\"Help Center\",\"url\":\"https:\/\/crocoblock.com\/knowledge-base\/\",\"logo\":{\"@type\":\"ImageObject\",\"inLanguage\":\"en-US\",\"@id\":\"https:\/\/crocoblock.com\/knowledge-base\/#\/schema\/logo\/image\/\",\"url\":\"https:\/\/crocoblock.com\/knowledge-base\/wp-content\/uploads\/2025\/04\/invert-crocoblock-logo.svg\",\"contentUrl\":\"https:\/\/crocoblock.com\/knowledge-base\/wp-content\/uploads\/2025\/04\/invert-crocoblock-logo.svg\",\"caption\":\"Help Center\"},\"image\":{\"@id\":\"https:\/\/crocoblock.com\/knowledge-base\/#\/schema\/logo\/image\/\"}}]}<\/script>\n<!-- \/ Yoast SEO plugin. -->","yoast_head_json":{"title":"Macros for WordPress Relations \u2014 JetEngine | Crocoblock","description":"Discover how to display the related parent, children, sibling, and grandparent posts, terms, users, and CCT items with the help of the WordPress JetEngine plugin.","robots":{"index":"index","follow":"follow","max-snippet":"max-snippet:-1","max-image-preview":"max-image-preview:large","max-video-preview":"max-video-preview:-1"},"canonical":"https:\/\/crocoblock.com\/knowledge-base\/jetengine\/jetengine-macros-for-wordpress-relations\/","og_locale":"en_US","og_type":"article","og_title":"Macros for WordPress Relations \u2014 JetEngine | Crocoblock","og_description":"Discover how to display the related parent, children, sibling, and grandparent posts, terms, users, and CCT items with the help of the WordPress JetEngine plugin.","og_url":"https:\/\/crocoblock.com\/knowledge-base\/jetengine\/jetengine-macros-for-wordpress-relations\/","og_site_name":"Help Center","article_modified_time":"2024-08-13T10:46:51+00:00","og_image":[{"url":"https:\/\/crocoblock.com\/knowledge-base\/wp-content\/uploads\/2022\/01\/legacy-and-refactoring-macros2.png"}],"twitter_card":"summary_large_image","twitter_misc":{"Est. reading time":"16 minutes"},"schema":{"@context":"https:\/\/schema.org","@graph":[{"@type":"WebPage","@id":"https:\/\/crocoblock.com\/knowledge-base\/jetengine\/jetengine-macros-for-wordpress-relations\/","url":"https:\/\/crocoblock.com\/knowledge-base\/jetengine\/jetengine-macros-for-wordpress-relations\/","name":"Macros for WordPress Relations \u2014 JetEngine | Crocoblock","isPartOf":{"@id":"https:\/\/crocoblock.com\/knowledge-base\/#website"},"datePublished":"2022-01-25T09:37:14+00:00","dateModified":"2024-08-13T10:46:51+00:00","description":"Discover how to display the related parent, children, sibling, and grandparent posts, terms, users, and CCT items with the help of the WordPress JetEngine plugin.","breadcrumb":{"@id":"https:\/\/crocoblock.com\/knowledge-base\/jetengine\/jetengine-macros-for-wordpress-relations\/#breadcrumb"},"inLanguage":"en-US","potentialAction":[{"@type":"ReadAction","target":["https:\/\/crocoblock.com\/knowledge-base\/jetengine\/jetengine-macros-for-wordpress-relations\/"]}]},{"@type":"BreadcrumbList","@id":"https:\/\/crocoblock.com\/knowledge-base\/jetengine\/jetengine-macros-for-wordpress-relations\/#breadcrumb","itemListElement":[{"@type":"ListItem","position":1,"name":"Home","item":"https:\/\/crocoblock.com\/knowledge-base\/"},{"@type":"ListItem","position":2,"name":"Articles","item":"https:\/\/crocoblock.com\/knowledge-base\/articles\/"},{"@type":"ListItem","position":3,"name":"Macros for WordPress Relations"}]},{"@type":"WebSite","@id":"https:\/\/crocoblock.com\/knowledge-base\/#website","url":"https:\/\/crocoblock.com\/knowledge-base\/","name":"Help Center","description":"","publisher":{"@id":"https:\/\/crocoblock.com\/knowledge-base\/#organization"},"potentialAction":[{"@type":"SearchAction","target":{"@type":"EntryPoint","urlTemplate":"https:\/\/crocoblock.com\/knowledge-base\/?s={search_term_string}"},"query-input":"required name=search_term_string"}],"inLanguage":"en-US"},{"@type":"Organization","@id":"https:\/\/crocoblock.com\/knowledge-base\/#organization","name":"Help Center","url":"https:\/\/crocoblock.com\/knowledge-base\/","logo":{"@type":"ImageObject","inLanguage":"en-US","@id":"https:\/\/crocoblock.com\/knowledge-base\/#\/schema\/logo\/image\/","url":"https:\/\/crocoblock.com\/knowledge-base\/wp-content\/uploads\/2025\/04\/invert-crocoblock-logo.svg","contentUrl":"https:\/\/crocoblock.com\/knowledge-base\/wp-content\/uploads\/2025\/04\/invert-crocoblock-logo.svg","caption":"Help Center"},"image":{"@id":"https:\/\/crocoblock.com\/knowledge-base\/#\/schema\/logo\/image\/"}}]}},"_links":{"self":[{"href":"https:\/\/crocoblock.com\/knowledge-base\/wp-json\/wp\/v2\/article\/26171"}],"collection":[{"href":"https:\/\/crocoblock.com\/knowledge-base\/wp-json\/wp\/v2\/article"}],"about":[{"href":"https:\/\/crocoblock.com\/knowledge-base\/wp-json\/wp\/v2\/types\/article"}],"author":[{"embeddable":true,"href":"https:\/\/crocoblock.com\/knowledge-base\/wp-json\/wp\/v2\/users\/11"}],"wp:attachment":[{"href":"https:\/\/crocoblock.com\/knowledge-base\/wp-json\/wp\/v2\/media?parent=26171"}],"wp:term":[{"taxonomy":"builder-category","embeddable":true,"href":"https:\/\/crocoblock.com\/knowledge-base\/wp-json\/wp\/v2\/builder-category?post=26171"},{"taxonomy":"article-category","embeddable":true,"href":"https:\/\/crocoblock.com\/knowledge-base\/wp-json\/wp\/v2\/article-category?post=26171"}],"curies":[{"name":"wp","href":"https:\/\/api.w.org\/{rel}","templated":true}]}}