Support

Account

Home Forums General Issues Add acf-field-group to acf_get_post_types

Solving

Add acf-field-group to acf_get_post_types

  • Hi!
    I have failed to write a proper filter that would add acf-field-group back to the Post Types dropdown.
    I tried the following:

    function kv_add_acf_field_group($exclude, $include) {
    	$key = array_search('acf-field-group', $exclude);
    	if ($key) : 
    		unset($exclude[$key]);
    	endif;
    	return $exclude;
    }
    
    add_filter('acf/get_post_types', 'kv_add_acf_field_group', 1, 3 );

    and

    function kv_add_acf_field_group($choices) {
    	$post_object = get_post_type_object('acf-field-group');
    	$choices['acf-field-group'] = $post_object;
    	return $choices;
    }
    
    add_filter('acf/get_post_types', 'kv_add_acf_field_group', 20, 3 );

    Neither of them worked. What did I do wrong?

  • I think the function you are looking for is ‘acf_get_post_types’ and it does not appear to be filterable. Look in api-helpers.php

    I would also like to be able to do this.

    Elliot, any chance of adding a filter into this function?

  • This would be a great feature, but it still looks like there’s no way to restore excluded post types.

    And it would be also be nice if, as an alternative to taxonomy filter, pages could be filtered by page template.

  • Hi Guys,

    I’m afraid you need to modify the core files to do it. If you want to submit a feature request, please submit a new ticket here: https://support.advancedcustomfields.com/new-ticket.

    Thanks 🙂

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

The topic ‘Add acf-field-group to acf_get_post_types’ is closed to new replies.