wp_insert_post categories array with variables
-
This code works:
$post_id = wp_insert_post( array( 'post_author' => $user_id, 'post_category' => array(3) )//some stuff omitted
This does not
$post_id = wp_insert_post( array( 'post_author' => $user_id, 'post_category' => array($category_id) )Using echo, $category_id is indeed 3, so I don’t get why this is not working. I’m guessing this has something to do with php and array creation but I couldn’t figure out what is wrong.
Viewing 2 replies - 1 through 2 (of 2 total)
Viewing 2 replies - 1 through 2 (of 2 total)
The topic ‘wp_insert_post categories array with variables’ is closed to new replies.