I am working on a custom theme where there is option to upload images . I have certain check-boxes in the form which the users select as per where the image has to go. My form code is as follows :
<input type="checkbox" class="input" name="vtype[]" value="3"/>
<input type="checkbox" class="input" name="vtype[]" value="4" />
<input type="checkbox" class="input" name="vtype[]" value="5" />
<input type="checkbox" class="input" name="vtype[]" value="6" />
function for using the values is :
$image_category = implode(',', $_POST['vtype']);
if i echo this then the result is fine e.g. 3,4,5 . but if i try to use this value to insert values in database then the value is updated in only the 1st category and nothing happens for the remaining.
main function is inserting values in database is :
$post = array(
'ID' => '',
'post_author' => $image_author,
'post_category' => array($image_category),
'post_content' => $image_to_attach,
'post_title' => $image_title,
'post_status' => 'publish'
);
}
// Insert the values in DB
$id = wp_insert_post($post);
array($image_category)
? Isn't$image_category
already an array?