Admin Columns + Revision (column) + sortable

Support MB Admin Columns Admin Columns + Revision (column) + sortable

Viewing 4 posts - 1 through 4 (of 4 total)
  • Author
    Posts
  • #41049
    SamSam
    Participant

    Hi - I need to be able to sort all posts (i'm using a CPT) by MB the Revision date. I basically need to see which post was modified most recently, and would like to use Revision field for that, as I will be looking at Revision data.

    I see https://docs.metabox.io/extensions/mb-admin-columns/#custom-admin-columns but don't know how to customize it for Revision date field (number of revisions would be a great second column if possible as well).

    Thansk you,
    Sam

    PS - You can discard my recent Question posted as reply to someone else's thread at https://support.metabox.io/topic/configure-admin-columns/?swcfpc=1#post-41046 as this takes its place.

    #41051
    SamSam
    Participant

    Hi - me again - Just wanted to say that the post "Last Modified" date would be perfectly sufficient for my purposes, too, if easier.

    Thanks again,
    Sam

    #41066
    PeterPeter
    Moderator

    Hello Sam,

    There is a trick to sort the posts by modified date. You can create a custom field date_picker and create an admin column to display this field value and sortable, then use the WordPress function get_the_modified_date() to get the modified date and update this data for the field.

    This is the example code:

    add_action( 'save_post', function( $post_id ) {
        $modified_date = get_the_modified_date( '', $post_id );
        update_post_meta( $post_id, 'date_field', $modified_date );
    } );

    You might need to check the post type or something else on your end. Please read more on the documentation
    https://developer.wordpress.org/reference/functions/get_the_modified_date/
    https://docs.metabox.io/extensions/mb-admin-columns/#3-advanced-configuration

    #41076
    SamSam
    Participant

    very cool. will try soon. thanks

Viewing 4 posts - 1 through 4 (of 4 total)
  • You must be logged in to reply to this topic.