Reputation: 593
// Auto post ( Unique File Date ).
$postData = array(
'post_category' => array( '0' ),
'post_status' => $Post_Status,
'post_type' => $Post_Type,
'post_date' => $File_Individual_Date
);
wp_insert_post( $postData );
when using 'post_category' => array( '0' ),
, it adds a post under the category Uncategorised
. What if I have a category in a var lets say:
$myCategory = 'News'
;
then using 'post_category' => $myCategory
gives error and no new post is added. Is it possible to add categories in this way?
Upvotes: 0
Views: 66
Reputation: 9951
Check the docs for wp_insert_post
post_category
should be an array of category ID's, so you would need to assign an array of category ID's to your variable for this to work
Upvotes: 1