Home › Forums › Gutenberg › Post Objects and get_field() in ACF Gutenberg Blocks › Reply To: Post Objects and get_field() in ACF Gutenberg Blocks
@brett I did something similar for an ACF block where I wanted to automatically show child pages, I set a var using
$page_id = get_queried_object_id(); and used that var to set the post parent:
$page_id = get_queried_object_id(); $args = array( 'post_type' => 'page', 'posts_per_page' => -1, 'post_parent' => $page_id, 'order' => 'ASC', 'orderby' => 'menu_order' ); $parent = new WP_Query( $args ); if ( $parent->have_posts() ) : ?>
This worked on the front end. Unfortunately for me this caused an issue in the WordPress admin – in WordPress admin screen all top level pages were showing. The slowed down my editing experience immensley so I instead opted to set the query using a tag instead of post parent.
Welcome to the Advanced Custom Fields community forum.
Browse through ideas, snippets of code, questions and answers between fellow ACF users
Helping others is a great way to earn karma, gain badges and help ACF development!