wp_delete_post_revision

Deletes a revision.

Description

(array|false|WP_Post|WP_Error|null) wp_delete_post_revision( (int|WP_Post) $revision_id ); 

Deletes the row from the posts table corresponding to the specified revision.

Returns (array|false|WP_Post|WP_Error|null)

Null or WP_Error if error, deleted post if success.

Parameters (1)

0. $revision_id (int|WP_Post)
Revision ID or revision object.

Usage

  1. if ( !function_exists( 'wp_delete_post_revision' ) ) { 
  2. require_once ABSPATH . WPINC . '/revision.php'; 
  3.  
  4. // Revision ID or revision object. 
  5. $revision_id = null; 
  6.  
  7. // NOTICE! Understand what this does before running. 
  8. $result = wp_delete_post_revision($revision_id); 
  9.  

Defined (1)

The function is defined in the following location(s).

/wp-includes/revision.php  
  1. function wp_delete_post_revision( $revision_id ) { 
  2. if ( ! $revision = wp_get_post_revision( $revision_id ) ) { 
  3. return $revision; 
  4.  
  5. $delete = wp_delete_post( $revision->ID ); 
  6. if ( $delete ) { 
  7. /** 
  8. * Fires once a post revision has been deleted. 
  9. * @since 2.6.0 
  10. * @param int $revision_id Post revision ID. 
  11. * @param object|array $revision Post revision object or array. 
  12. */ 
  13. do_action( 'wp_delete_post_revision', $revision->ID, $revision ); 
  14.  
  15. return $delete;