I have a custom taxonomy registered and I want to add a category to the post via a PHP function. The category I am try to add to the post is registered under a custom taxonomy.
I've tried using wp_set_object_terms
, wp_set_post_categories
, and wp_set_post_terms
to no avail.
register_taxonomy('deals_tiers', array( 'deals' ), array(
'label' => 'Deals Tiers',
'hierarchical' => true,
'public' => true,
'query_var' => true,
'show_ui' => true,
'show_in_rest' => true,
'rest_base' => 'deals_tiers',
'rest_controller_class' => 'WP_REST_Terms_Controller',
) );
I'd like the post to have the category 'Spotlight'
added to it and I have spotlight registered as a deals_tier
with an id of 183