wp_delete_post() deletes post instead of moving it to trash

Following the line of code https://core.trac.wordpress.org/browser/tags/4.9/src/wp-includes/post.php#L2467 if ( ! $force_delete && ( ‘post’ === $post->post_type || ‘page’ === $post->post_type ) && ‘trash’ !== get_post_status( $postid ) && EMPTY_TRASH_DAYS ) { return wp_trash_post( $postid ); } the $force_delete just work with ‘post’ and ‘page’, it not work with custom post type

How do I programatically empty trash?

You can use wp_delete_post. To get all posts with the “trash” status: $trash = get_posts(‘post_status=trash&numberposts=-1’); Then: foreach($trash as $post) wp_delete_post($post->ID, $bypass_trash = true);

Hata!: SQLSTATE[HY000] [1045] Access denied for user 'divattrend_liink'@'localhost' (using password: YES)