Revision Count in Posts Admin Screen in WordPress

This Post discusses how you can add Revision Count in Posts Admin Screen in WordPress.

In order to show Revision Count as a Column in Posts Page Admin Screen, add below filter and action in functions.php of your theme.

// register custom column
add_filter( 'manage_posts_columns', 'custom_posts_table_head' );

function custom_posts_table_head( $columns ) {

    $columns['revisions']  = 'Revisions';
    
    return $columns;

}

// values to display in custom column
add_action( 'manage_posts_custom_column', 'custom_posts_table_content', 10, 2 );

function custom_posts_table_content( $column_name, $post_id ) {

    if( $column_name == 'revisions' ) {
        
        $args = array(
			'post_parent' => $post_id,
			'post_type' => 'revision',
			'post_status' => 'inherit'
		);
		$query = get_children($args);
		
	    $count = count($query);

        echo '<strong>' . $count . '</strong>';
    }
}

Leave a Reply

Your email address will not be published.