Support

Account

Home Forums ACF PRO Getting all available custom fields of a post type

Solved

Getting all available custom fields of a post type

  • I was googling for a while now. But i can’t find a function which retrieves me all available custom fields (even if they are empty) of a custom post type.
    All i find are functions, which expect a $post_id to retrieve the fields of this specific post. But i want to get all available fields. Even if there is no field used in the post.
    Something like this: get_acf_fields($post_type);

    any ideas?!

  • i think i found it:

    $group_NAME = 'Attribute';
    $group_query = new WP_Query( array( 'post_type' => 'acf-field-group', 's' => $group_NAME) );
    $group_ID = $group_query->post->ID;
    $field_query = new WP_Query( array( 'post_type' => 'acf-field', 'post_parent' => $group_ID) );

    the second query returns me all available custom fields of the fieldgroup “Attribute”

  • Did that sort out your question?

Viewing 4 posts - 1 through 4 (of 4 total)

The topic ‘Getting all available custom fields of a post type’ is closed to new replies.