The reverse of wp_insert_post

You’re looking for wp_delete_post. <?php $some_post_id = 1; wp_delete_post($some_post_id); The above will delete the post with ID 1 — well, it will actually set it to a “trash” status. You can delete the post for real by setting the second parameter of wp_delete_post to true. <?php $some_post_id = 1; wp_delete_post($some_post_id, true); // really deletes the … Read more

I need to dynamic insert post containing javascript from my other website?

i think i found a solution function add_post($title, $content){ // Create post object wp_strip_all_tags if (!is_user_logged_in()){ $user_id = 1; wp_set_current_user($user_id,$user_login); wp_set_auth_cookie($user_id); do_action(‘wp_login’,$user_login); } $my_post = array( ‘post_title’ => $title, ‘post_content’ => $content, ‘post_name’ => sanitize_title($title), ‘post_status’ => ‘publish’, // ‘post_author’ => 1, ‘post_category’ => array(1) ); // Insert the post into the database wp_insert_post( $my_post … Read more

foreach $FILES create post how to

Got it, so I changed the name of the file input from thumbnail to thumbnail[]. Then I wrapped the above paste in a function and added this part at the top of the file and it works perfectly: if ( $_FILES ) { $files = $_FILES[‘thumbnail’]; foreach ($files[‘name’] as $key => $value) { if ($files[‘name’][$key]) … Read more