Hi!
I'm making a form on a wp page from where I'll post posts.
My problem is that I don't know how to get the categories from a <select name"col1"><option> Formular.
Here is my code:
if(isset($_POST['Col1']) && !empty($_POST['Col1'])){
$Col1_Array = $_POST['Col1'];
$a='';
foreach($Col1_Array as $selectValue){
$a= $a.$selectValue.",";
}
}
// Create post object
$my_post = array();
$my_post['post_title'] = stripslashes($_POST['titre']);
$my_post['post_content'] = stripslashes($_POST['description']);
$my_post['post_status'] = get_user_post_status ();
$my_post['post_author'] = $current_user->ID;
$my_post['post_category'] = array($a.'1');
// Insert the post into the database
wp_insert_post( $my_post );
this code only post on the first category that is selected.
What can I change to make it right?
Thanks