I'm new to Wordpress and php,so sorry for my basic question. I want to add some posts in a category programmatically. For example every day i want to select some posts and insert them into a category with php code and for next day replace some other posts. Is it possible? How? Thanks in advance.
You can use wp_insert_post
https://codex.wordpress.org/Function_Reference/wp_insert_post
See the Codex, here you have a lot of examples:
// Create post object
$my_post = array(
'post_title' => 'My post',
'post_content' => 'This is my post.',
'post_status' => 'publish',
'post_author' => 1,
'post_category' => array(8,39)
);
// Insert the post into the database
wp_insert_post( $my_post );
To update the Post see wp_update_post
https://codex.wordpress.org/Function_Reference/wp_update_post
If you love us? You can donate to us via Paypal or buy me a coffee so we can maintain and grow! Thank you!
Donate Us With