{"id":6663,"date":"2024-02-04T15:11:11","date_gmt":"2024-02-04T04:11:11","guid":{"rendered":"https:\/\/brickslabs.com\/?p=6663"},"modified":"2024-09-25T14:31:16","modified_gmt":"2024-09-25T04:31:16","slug":"parent-post-bricks-query-loop","status":"publish","type":"post","link":"https:\/\/brickslabs.com\/parent-post-bricks-query-loop\/","title":{"rendered":"Parent post Bricks query loop"},"content":{"rendered":"<div class=\"mp_wrapper\">\n  <div class=\"mepr-unauthorized-excerpt\">\n    <p><em>Updated on 5 Feb 2024<\/em><\/p>\n<p>In the <a href=\"https:\/\/www.facebook.com\/groups\/brickslabs\/\" target=\"_blank\" rel=\"noreferrer noopener\">BricksLabs Facebook group<\/a> a user asks:<\/p>\n<blockquote class=\"wp-block-quote is-layout-flow wp-block-quote-is-layout-flow\">\n<p>Is there a way to output the data of a parent post in a child post?<\/p>\n<p>Are there tutorials for this?<\/p>\n<\/blockquote>\n<p>This <a href=\"https:\/\/brickslabs.com\/pro-tutorial\" target=\"_blank\" rel=\"noreferrer noopener\">Pro tutorial<\/a> provides the steps to output the current single post's parent post using a <a href=\"https:\/\/brickslabs.com\/go\/bricks\" target=\"_blank\" rel=\"noreferrer noopener\">Bricks<\/a> query loop for hierarchical post types.<\/p>\n<figure class=\"wp-block-image size-large\"><img src=\"https:\/\/brickslabs.com\/wp-content\/uploads\/2024\/02\/parent-post-bricks-query-loop-1024x269.png\" alt=\"\" class=\"wp-image-6666\" \/><\/figure>\n<p>When viewing the child post:<\/p>\n<figure class=\"wp-block-image size-large\"><a href=\"https:\/\/brickslabs.com\/wp-content\/uploads\/2024\/02\/parent-post-bricks-query-loop.jpg\"><img src=\"https:\/\/brickslabs.com\/wp-content\/uploads\/2024\/02\/parent-post-bricks-query-loop-1024x746.jpg\" alt=\"\" class=\"wp-image-6667\" \/><\/a><\/figure>\n<h2 class=\"wp-block-heading\">Step 1<\/h2>\n<p>Create and edit your single post type template with Bricks.<\/p>\n<figure class=\"wp-block-image size-full is-resized\"><img src=\"https:\/\/brickslabs.com\/wp-content\/uploads\/2024\/02\/CleanShot-2024-02-04-at-12\u202f.00.41@2x.png\" alt=\"\" class=\"wp-image-6668\" \/><\/figure>\n<p>Add a Section for showing the parent post data (bottom Section in the screenshot).<\/p>\n<p>Sample JSON provided near the end for copy-pasting.<\/p>\n<p>Set up a query loop inside.<\/p>\n<p>Click the query icon and enable PHP query editor.<\/p>\n<p>Paste:<\/p>\n  <\/div>\n  <div class=\"mepr-unauthorized-message\">\n    <p>This is a BricksLabs Pro tutorial.<\/p>\n<p>For full access login below or create your <a href=\"https:\/\/brickslabs.com\/pro\/\">BricksLabs Pro account<\/a><\/p>\n  <\/div>\n  <div class=\"mepr-login-form-wrap\">\n            \n<div class=\"mp_wrapper mp_login_form\">\n                  <!-- mp-login-form-start -->     <form name=\"mepr_loginform\" id=\"mepr_loginform\" class=\"mepr-form\" action=\"https:\/\/brickslabs.com\/login\/\" method=\"post\">\n            <div class=\"mp-form-row mepr_username\">\n        <div class=\"mp-form-label\">\n                              <label for=\"user_login\">Username<\/label>\n        <\/div>\n        <input type=\"text\" name=\"log\" id=\"user_login\" value=\"\" \/>\n      <\/div>\n      <div class=\"mp-form-row mepr_password\">\n        <div class=\"mp-form-label\">\n          <label for=\"user_pass\">Password<\/label>\n          <div class=\"mp-hide-pw\">\n            <input type=\"password\" name=\"pwd\" id=\"user_pass\" value=\"\" \/>\n            <button type=\"button\" class=\"button mp-hide-pw hide-if-no-js\" data-toggle=\"0\" aria-label=\"Show password\">\n              <span class=\"dashicons dashicons-visibility\" aria-hidden=\"true\"><\/span>\n            <\/button>\n          <\/div>\n        <\/div>\n      <\/div>\n            <div>\n        <label><input name=\"rememberme\" type=\"checkbox\" id=\"rememberme\" value=\"forever\" \/> Remember Me<\/label>\n      <\/div>\n      <div class=\"mp-spacer\">&nbsp;<\/div>\n      <div class=\"submit\">\n        <input type=\"submit\" name=\"wp-submit\" id=\"wp-submit\" class=\"button-primary mepr-share-button \" value=\"Log In\" \/>\n        <input type=\"hidden\" name=\"redirect_to\" value=\"\/wp-json\/wp\/v2\/posts\/6663\" \/>\n        <input type=\"hidden\" name=\"mepr_process_login_form\" value=\"true\" \/>\n        <input type=\"hidden\" name=\"mepr_is_login_page\" value=\"false\" \/>\n      <\/div>\n    <\/form>\n    <div class=\"mp-spacer\">&nbsp;<\/div>\n    <div class=\"mepr-login-actions\">\n        <a\n          href=\"https:\/\/brickslabs.com\/login\/?action=forgot_password\"\n          title=\"Click here to reset your password\"\n        >\n          Forgot Password        <\/a>\n    <\/div>\n\n      \n    <!-- mp-login-form-end --> \n  <\/div>\n      <\/div>\n<\/div>\n","protected":false},"excerpt":{"rendered":"<p>Updated on 5 Feb 2024 In the BricksLabs Facebook group a user asks: Is there a way to output the data of a parent post in a child post? Are there tutorials for this? This <a  class=\"btl_autolink_hyperlink\"  href=\"https:\/\/brickslabs.com\/pro-tutorial\"   >Pro tutorial<\/a> provides the steps to output the current single post&#8217;s parent post using a <a  class=\"btl_autolink_hyperlink\"  href=\"https:\/\/brickslabs.com\/go\/bricks\"   >Bricks<\/a> query loop for hierarchical [&hellip;]<\/p>\n","protected":false},"author":1,"featured_media":6667,"comment_status":"open","ping_status":"open","sticky":false,"template":"","format":"standard","meta":{"_acf_changed":false,"_seopress_robots_primary_cat":"none","_seopress_titles_title":"","_seopress_titles_desc":"","_seopress_robots_index":"","footnotes":""},"categories":[5,9],"tags":[22],"topic":[266],"class_list":["post-6663","post","type-post","status-publish","format-standard","has-post-thumbnail","hentry","category-bricks","category-pro","tag-query-loop","topic-query-loop"],"acf":[],"featured_image_src":"https:\/\/brickslabs.com\/wp-content\/uploads\/2024\/02\/parent-post-bricks-query-loop-600x400.jpg","featured_image_src_square":"https:\/\/brickslabs.com\/wp-content\/uploads\/2024\/02\/parent-post-bricks-query-loop-600x600.jpg","author_info":{"display_name":"Sridhar Katakam","author_link":"https:\/\/brickslabs.com\/author\/sridhar\/"},"_links":{"self":[{"href":"https:\/\/brickslabs.com\/wp-json\/wp\/v2\/posts\/6663","targetHints":{"allow":["GET"]}}],"collection":[{"href":"https:\/\/brickslabs.com\/wp-json\/wp\/v2\/posts"}],"about":[{"href":"https:\/\/brickslabs.com\/wp-json\/wp\/v2\/types\/post"}],"author":[{"embeddable":true,"href":"https:\/\/brickslabs.com\/wp-json\/wp\/v2\/users\/1"}],"replies":[{"embeddable":true,"href":"https:\/\/brickslabs.com\/wp-json\/wp\/v2\/comments?post=6663"}],"version-history":[{"count":0,"href":"https:\/\/brickslabs.com\/wp-json\/wp\/v2\/posts\/6663\/revisions"}],"wp:featuredmedia":[{"embeddable":true,"href":"https:\/\/brickslabs.com\/wp-json\/wp\/v2\/media\/6667"}],"wp:attachment":[{"href":"https:\/\/brickslabs.com\/wp-json\/wp\/v2\/media?parent=6663"}],"wp:term":[{"taxonomy":"category","embeddable":true,"href":"https:\/\/brickslabs.com\/wp-json\/wp\/v2\/categories?post=6663"},{"taxonomy":"post_tag","embeddable":true,"href":"https:\/\/brickslabs.com\/wp-json\/wp\/v2\/tags?post=6663"},{"taxonomy":"topic","embeddable":true,"href":"https:\/\/brickslabs.com\/wp-json\/wp\/v2\/topic?post=6663"}],"curies":[{"name":"wp","href":"https:\/\/api.w.org\/{rel}","templated":true}]}}