I'm attempting to show only parent pages of a custom post type using Advanced Custom Fields Post Object field. Then I'm using Advanced Forms to show the form on the front-end. The problem is that I can't seem to figure out how show only parent pages from a custom post type.
Currently, it is outputting all posts, pages and custom post types pages on the front-end: !https://i.ibb.co/tXkxFdY/Screen-Shot-2019-04-01-at-2-50-25-PM.png
For reference, here is how my Post Object settings is set up in the ACF Pro plug-in: !https://i.ibb.co/Z6W3cjF/Screen-Shot-2019-04-01-at-2-44-24-PM.png
I tried using the following the ACF Post Object query from: https://www.advancedcustomfields.com/resources/acf-fields-post_object-query/
Using the ACF page "acf/fields/post_object/query" https://www.advancedcustomfields.com/resources/acf-fields-post_object-query/
I tried using the following:
function my_relationship_query( $args, $field, $post_id ) {
$args = array(
'post_parent' => $post_id, // updated to use the current $post_id
'post_type' => 'mediakit',
'numberposts' => -1,
'post_status' => 'published'
);
return;
}
// filter for every field
add_filter('acf/fields/relationship/query/key=field_5ca24f099f985', 'my_relationship_query', 10, 3);
I was hoping the results on the front-end would show the select showing only parent pages of the custom post type, on the front-end.
The actual results is showing all the posts, pages and all the pages in the custom post type.
Any help on this problem will be greatly appreciated.