I have created a new category named World News and the slug name is worldnews.
I have a PHP code that would generate a post and insert the post to Wordpress. However, when I enter the category using the "post_category" function with "worldnews", I am not able to update the category to the post. This cause the post to have a non-category post.
Can you feedback, on what is the right way to enter the category from PHP for this theme? Do I need to use some ID value?
I have created a new category named World News and the slug name is worldnews.
I have a PHP code that would generate a post and insert the post to Wordpress. However, when I enter the category using the "post_category" function with "worldnews", I am not able to update the category to the post. This cause the post to have a non-category post.
Can you feedback, on what is the right way to enter the category from PHP for this theme? Do I need to use some ID value?
Hi,
Please read this document about WP Insert Post: https://developer.wordpress.org/reference/functions/wp_insert_post/
The "post_category" only accepts category ID, so please find the Category ID of the category then tries again.
Regards,
PenciDesign.
Thanks for the feedback! I managed to solve this based on the feedback you provided.