# Revisions Count Column

> Adds a Revisions column to the Posts and Pages lists showing how many saved revisions each item has, linking to the revision browser, to find heavily edited content.

- Type: PHP
- Runs: Admin only
- Category: [Admin](https://wpide.com/library/category/admin/)
- Tags: admin-columns, revisions, posts
- Author: WPIDE Team
- Installs: 0
- Updated: 2026-10-28
- Page: https://wpide.com/library/admin-revisions-count-column/

## Code

```php
$wpide_revision_counts = null;

$wpide_revisions_cell = function ( $column, $post_id ) use ( &$wpide_revision_counts ) {
    if ( 'wpide_revisions' !== $column ) {
        return;
    }

    if ( null === $wpide_revision_counts ) {
        global $wpdb, $wp_query;
        $ids                   = $wp_query && $wp_query->posts ? array_map( 'absint', wp_list_pluck( $wp_query->posts, 'ID' ) ) : array( (int) $post_id );
        $wpide_revision_counts = wp_list_pluck( $wpdb->get_results(
            "SELECT post_parent, COUNT(*) AS total FROM {$wpdb->posts} WHERE post_type = 'revision' AND post_parent IN (" . implode( ',', $ids ? $ids : array( 0 ) ) . ') GROUP BY post_parent'
        ), 'total', 'post_parent' );
    }

    $count = (int) ( $wpide_revision_counts[ $post_id ] ?? 0 );
    if ( ! $count ) {
        echo '0';
        return;
    }
    $latest = wp_get_post_revisions( $post_id, array( 'posts_per_page' => 1, 'fields' => 'ids' ) );
    printf( '<a href="%s">%d</a>', esc_url( admin_url( 'revision.php?revision=' . (int) reset( $latest ) ) ), $count );
};

foreach ( array( 'post', 'page' ) as $wpide_type ) {
    add_filter( "manage_{$wpide_type}_posts_columns", function ( $columns ) {
        $columns['wpide_revisions'] = 'Revisions';
        return $columns;
    } );
    add_action( "manage_{$wpide_type}_posts_custom_column", $wpide_revisions_cell, 10, 2 );
}
```

## Notes

Counts come from one grouped query per screen.

## How to use it

Install the free WPIDE plugin (https://wordpress.org/plugins/wpide/), find "Revisions Count Column" in its snippet library and add it in one click; or create a new PHP snippet in WPIDE (or any code snippets plugin) and paste the code above. More snippets: https://wpide.com/library/
