I'm starting to use Carbon Fields (with Wordpress) and I'm having a problem.
- I installed Wordpress v.6.0.1 on localhost (Windows 10, OpenServer, PHP 8.0, MySQl 8.0);
- Then I installed Carbon Fields using composer.
- I created several categories and one post.
- I created an association field using Carbon Fields to select post categories from the field
use Carbon_Fields\Container;
use Carbon_Fields\Field;
add_action( 'carbon_fields_register_fields', 'crb_attach_post_fields' );
function crb_attach_post_fields() {
Container::make( 'post_meta', 'Post settings' )
->where( 'post_type', '=', 'post' )
->add_fields( array(
Field::make( 'association', 'crb_category', 'Category' )
->set_types( array(
array(
'type' => 'term',
'taxonomy' => 'category',
)
) )
));
}
add_action( 'after_setup_theme', 'crb_load' );
function crb_load() {
require_once( 'vendor/autoload.php' );
\Carbon_Fields\Carbon_Fields::boot();
}
You are mixin two topics that could seem related:
The front side right panel on categories as you show in your image 4 is managed by WordPress along with the
count
column that you have established. Even though when you use the association carbon field with the categories term, you get the same list of calories that WordPress uses as well when you save your post the carbon fields store this relation in its own fields, so Worpress is not notified that you select these categories because to Wordpres is similar to other custom fields.In summary, the category terms are store and management by WordPress and the association that you create with CarbonFields is management by yourself.