Skip to main content

How to Display Child Posts on Parent Post Pages and Vice Versa

This guide will walk you through displaying child posts on a parent single post page, or displaying parent posts on a child single post page. Follow these steps to set up relationships and queries for a seamless parent-child post display.

Updated over 2 months ago

Step 1: Create a Relationship Between Custom Post Types (CPTs)

This step involves navigating to JetEngine > Relations, defining the relationship type such as Parent ↔ Child, and organizing relationships for your Custom Post Types effectively. These components define how related entries interact dynamically.

  1. Navigate to JetEngine > Relations to establish a connection between your Custom Post Types (CPTs).

  2. Define the relationship type (e.g., Parent ↔ Child or Many-to-Many) and give it a descriptive name.

  3. Save the relation and attach appropriate items/posts to these relationships in your administrative content setup.

  4. For further guidance, you can follow this detailed guide on relationships.


Step 2: Display Child Posts on the Parent Post Page

  1. Set Up the Query:

    • Go to JetEngine Query Builder and create a new Posts Query.

    • In the General tab, select your Child CPT and specify the post status.

    • Set up the query to retrieve related items:

  2. Use the Query:

    • Now, you can use this query as a custom query in the listing where you want the child posts to appear.


Step 3: Display Parent Posts on the Child Post Page

  1. Set Up the Query in Query Builder:

    • Open the JetEngine Query Builder and create a Posts Query for the parent post type.

    • In the General tab, select your Parent CPT.

    • Use the "Related Items" macro to link the parent post to the current child post:

  2. Add Parent Listing to Child Post Page:

    • Finally, add the parent listing to the child post page (or to a child post listing) and apply the custom query.


Following these steps, you can display child posts on a parent post page or parent posts on a child post page using JetEngine's Query Builder.
​

Did this answer your question?