How do I get post information from several query steps deeper?

Hi,
I’m trying to get the post information a few query levels deeper than the original post.
In other words, the post id of the original post to query for the information or best practices on how to do this. :sweat_smile:

I have a post “My post” that has content and a relationship to another post type. This post type “My post X” has a similar structure, so I am one level down. I’m not sure how to describe this, so here’s a picture.

grafik
You can also think of the picture as the post I’m trying to create.

Each of these my posts is a different post type! I am able to retrieve the data from “2.2.2 Other XX” and am now stuck there. How do I get the information from “3. Other” down to “2.2.2 Other XX”?

I am not able to use a meta query to get the information I need because “2.1 My post X” is in several other post types "1. The same applies to the level below.

So my thought was to get the “3. Other Stuff” information about the parent “1. My Post” of the parent “2.1. My Post X” of “2.2.1. My Post XX”. :woozy_face:

I tried using in parent or post parent in the query editor, but couldn’t get any results. The documentation does not contain any information on this.
grafik

On another thought it could be easiest to just retrieve the original post ID from “1. My post” and query the content. But I don’t know how to do that. :thinking:

Hope I was able to describe my question to some extent.

Cheers

@T-low , I thought about it for a while but couldn’t figure out a no-code solution. It has more to do with the way WordPress handles post queries than a Cwicly shortcoming. I believe that Cwicly Query Block is essentially a WordPress Query Loop.

For your specific use-case, if you are trying to access data of the main post (main query), then an option would be to access the global $wp_query and retrieve the data you need from there.

Maybe that’s not an elegant solution. But that’s the best I have right now :smiley: .

For example, this code will echo the post title and an ACF field of the main queried post:

global $wp_query;
echo $wp_query->post->post_title;
echo get_field('my_acf_field', echo $wp_query->post->ID);

And in a code block:
image