• I have a site that has posts that are individual products, and site-side display order is based on categories. Admin side, I would like the list of posts in wp-admin/edit.php to be able to display and sort by latest Modified date instead of published date, because I need to see which posts are the least recently modified so I can update them, and I don’t care when they were first published.

    In spite of searching high and low on these forums, the web, and plugins for a simple answer or something that will let me do this, I’ve had no luck and it’s a bit beyond my ken to know exactly what to look for and where in the files at the moment.

    Just guessing that the edit will need to happen somewhere in one of these:
    class-wp-list-table.php
    class-wp-posts-list-table.php
    Or edit.php ?

    And to be looking for an orderby=post_status or something to change it to orderby=modified_date

    Any help would be greatly appreciated.

Viewing 3 replies - 1 through 3 (of 3 total)
  • Thread Starter C450104

    (@c450104)

    Ok, so still digging for answers, found this page:

    Curtiss Grymala Member Posted 8 months ago
    Obviously, you shouldn’t actually modify edit.php, as any changes will be overwritten when you upgrade WordPress.
    However, you can try to use the manage_posts_columns filter to add a new column showing the scheduled/published time.

    Which lead me to this:
    https://scompt.com/blog/archives/2007/10/20/adding-custom-columns-to-the-wordpress-manage-posts-screen

    It doesn’t have an example of my specific need, but I’ll keep looking to see if I stumble onto something.

    So now at least I know I shouldn’t be messing with the edit.php or any other files like that.

    Thread Starter C450104

    (@c450104)

    Woot! My issue is resolved! Found something that does what I needed:
    https://www.ads-software.com/extend/plugins/custom-admin-column/

    This came with 2 default new columns that it added to the Posts page that I didn’t really need, but gave me the plugin framework I needed to tweak and add what I wanted.

    For anyone coming after me, in the custom_admin_columns.php file, find:

    function cac_post_column_filter($columns) {
        $columns['thumbnail'] = 'Featured Image';
        $columns['slug'] = 'Permalink';
        return $columns;
      }
    add_filter('manage_post_posts_columns', 'cac_post_column_filter');

    After $columns['slug'] = 'Permalink'; Add:
    $columns['date_modified'] = 'Date Modified';
    Then find:

    function cac_column_value($name, $id){
    switch($name){
    case 'slug':
           $permalink = get_permalink($id);
    	echo '<a href="'. $permalink . '" target="_blank">' . $permalink . '</a>';
    	break;
    case 'thumbnail':
       if(function_exists('get_the_post_thumbnail'))
    	echo get_the_post_thumbnail($id, array(75,75));
       break;

    After the Thumbnail case, add:

    case 'date_modified':
    	if(function_exists('the_modified_date'))
    		echo the_modified_date();
    	break;

    Reference: https://codex.www.ads-software.com/Function_Reference/the_modified_date

    I also added a few other custom post field columns to my file from using ADV Custom Fields:
    https://www.ads-software.com/extend/plugins/advanced-custom-fields/

    If anyone ever wants to know how I’ve implemented those, feel free to email me or reply to this post, I’m subscribed.

    Thread Starter C450104

    (@c450104)

    I think I’ll probably be using this guide to expand the functionality of my custom fields by adding them to the Quick Edit section of my site:
    https://shibashake.com/wordpress-theme/expand-the-wordpress-quick-edit-menu

    …And I’m just posting this here for posterity’s sake.

Viewing 3 replies - 1 through 3 (of 3 total)
  • The topic ‘Sort Admin edit.php Post List By Modified Instead of Published’ is closed to new replies.