Tax Archives – Set Term

/**
 * Automatically add our taxonomy term upon publish.
 *
 * Term needs to already be created in the database.
 *
 * @since 1.0.0
 *
 * @param int $post_id Published post ID.
 */
function pluginize_auto_add_taxonomy_terms_on_publish( $post_id = 0 ) {
    if ( ! wp_is_post_revision( $post_id ) ) {
        $terms = [ 23 ]; // Set to the appropriate term ID for your "all" term.
        wp_set_object_terms( $post_id, $terms, 'mustards' ); // Set to your custom taxonomy slug.
    }
}