Home Forums Backend Issues (wp-admin) Manage "uncategorized" category with ACF custom field


Manage "uncategorized" category with ACF custom field

  • Hello

    I would like to manage the selection of categories associated with posts through an ACF taxonomy field.

    To do this, however, I have to manage the “uncategorized” category, removing it from the options available in the custom field and, if the user does not select any category, this is automatically associated with the post and disassociated if a category is selected instead.

    To do this I inserted two filters:

    add_filter('acf/fields/taxonomy/wp_list_categories/key=field_60871d724a420', 'tp_exclude_uncategorized_category', 999, 2);
    function tp_exclude_uncategorized_category( $args, $field ){
    	if( ! is_admin() ) return $args;
    	$args['exclude'] = array(1);
    	return $args;
    add_filter('acf/update_value/key=field_60871d724a420', 'tp_set_uncategorized_category', 999, 4);
    function tp_set_uncategorized_category($value, $post_id, $field, $original){
    	if( !is_array($value) || !count($value) ) return array(1); // 1 = Uncategorized
    	return $value;

    The first hides the “uncategorized” category from the available options, the second SHOULD handle the update, but unfortunately it doesn’t seem to work. Every time I update, without selecting the available categories, the post is not associated with any category. It seems that the filter ‘acf/update_value’ does nothing and it is ignored even if I add a “die();” function.

Viewing 1 post (of 1 total)

You must be logged in to reply to this topic.