wp_insert_post custom taxonomy multiple Category not added

I have a custom post type jobs and a custom taxonomy jobCategory. wp_insert_post() and it works. When a user selects multiple jobCategory, only one selected category is recorded in the database. please guide me

if (isset($_POST['send'])) {
    $post_id = wp_insert_post(array(
        'post_type' = 'jobs',
        'post_author' = get_current_user_id(),
        'post_title' = $_POST['title'],
        'post_content' = $_POST['description'],
        'post_status' = 'draft',
    ));
    wp_set_object_terms($post_id, intval($_POST['category']), 'jobCategory');
    add_post_meta($post_id, 'price', $_POST['price']);
    add_post_meta($post_id, 'time', $_POST['time']);
    if (isset($_FILES['file'])) {
        require_once(ABSPATH . 'wp-admin/includes/file.php');
        $uploadedfile = $_FILES['file'];
        $upload_overrides = array(
            'test_form' = false
        );
        $movefile = wp_handle_upload($uploadedfile, $upload_overrides);
        add_post_meta($post_id, 'file', $movefile['url']);
        add_post_meta($post_id, 'payToSee', 0);}
    wp_redirect('my-ads');
}

HTML SECTION

                    div class=col-12
                    div class=card
                        div class=card-body
                            form action= method=POST enctype=multipart/form-data
                                div class=form-group
                                    label for=titleTitle/label
                                    input required type=text id=title name=title class=form-control
                                /div
                                div class=form-group
                                    label for=descriptiondetails/label
                                    textarea name=description id=description class=form-control cols=30 rows=10/textarea
                                /div
                                div class=form-group
                                    label for=categorycategory/label
                                    select id=js-choice id=category name=category[] multiple=multiple
                                      ?php
                                      $terms = get_terms([
                                        'taxonomy' = 'jobCategory',
                                        'hide_empty' = false,
                                      ]);
                                      foreach ($terms as $cat) {
                                        ?
                                        option value=?= $cat-term_id ??= $cat-name ?/option
                                        ?php
                                      }
                                      ?
                                    /select
                                /div
                                div class=form-group
                                    label for=pricePrice/label
                                    input required type=text id=price name=price class=form-control
                                /div
                                div class=form-group
                                    label for=timeTime/label
                                    input required type=text id=time name=time class=form-control
                                /div
                                div class=form-group
                                    label for=fileFiles/label
                                    input type=file id=file name=file class=form-control
                                /div
                                button value=1 name=send type=submit class=btn text-center btn-primarySubmit
                                /button
                            /form
                        /div
                    /div
                /div

Topic wp-insert-post taxonomy customization Wordpress

Category Web

About

Geeks Mental is a community that publishes articles and tutorials about Web, Android, Data Science, new techniques and Linux security.