How can I auto-assign a CPT post to category in a custom taxonomy when published?

As Documentation says, wp_set_object_terms accepts 4 arguments: $object_id, $terms, $taxonomy, $append object_id – ID of post, page, attachment or anything which is in post table terms – slug(s) or id(s) or term(s) taxonomy – slug of taxonomy – in your case it will be you custom taxonomy slug append – whether delete all existing terms … Read more

AJAX response, edit tags

Wait for WordPress 4.7 on 6th December. It has this almost built-in. If I got it right, then you’ll want to prevent some terms from deletion. I already made a snippet for that which works with WP 4.7 add_filter( ‘user_has_cap’, function ( $allcaps, $caps, $args ) { if ( ! isset( $args[0] ) || ‘delete_term’ … Read more

Limit number of terms that a custom taxonomy can save per custom post type

Taxonomy Single Term is a small library that helps to implemement this functionality. Usage Include the class.taxonomy-single-term.php file from within your plugin or theme Initialize the class (update the taxonomy slug with your own): $custom_tax_mb = new Taxonomy_Single_Term( ‘custom-tax-slug’ ); Optional The second parameter is an array of post_types and the third parameter is either … Read more