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!
📣 “ACF Chat Fridays”— Advanced Custom Fields (@wp_acf) January 31, 2023
The ACF team holds their first open office hours this Friday! Come and talk ACF, and ask questions about building sites with the plugin.
We’d love to see you there!
📆 Friday 3rd Feb - 3pm UTC
👉 Register here - https://t.co/3UtvQbE4CU pic.twitter.com/oTwW9K1XQ0
© 2023 Advanced Custom Fields.