Is there any point to using wp_unique_post_slug?

As the commenters have noticed wp_unique_post_slug is called from wp_insert_post to ensure there are no double slugs. It is also called from two other functions, which explains why it is a separate function and not incorporated in wp_insert_post. A little used feature is the possibility to apply filters present in wp_unique_post_slug. There are two of … Read more

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

upload images on front by user using form

If all you do is update ACF fields with your form, why not use the built-in function to generate the form? Create a new ACF field for the images, or simply use the Gallery field type, then display the form using acf_form: <?php acf_form(array( ‘post_id’ => ‘new_post’, ‘new_post’ => array( ‘post_type’ => ‘vendre’, ‘post_status’ => … Read more

wp_insert_post() get Fatal Error from Plugin

So If I understand correctly you are creating a custom import plugin to wordpress outside the normal wordpress scope. Therefore you don’t have access to the functions inside .pluggable.php like is_user_logged_in you can redefine them in your plugin or you can just use require_once( ABSPATH . “wp-includes/pluggable.php” ); You will also not be able to … Read more