• Hello, I just started using Types today, and I love the concept. I’m also interested in integrating Views to allow me to do wonders. However, there is one feature which is missing in Types: the ability to view/sort custom fields as columns in the admin post list view.

    I’ve spent a few hours trying to implement this, and I see that many people have requested this feature. I finally managed it, so here is the code for everyone who is searching. Add this in your functions.php:

    //Add custom column
    add_filter('manage_edit-YOURPOSTTYPENAME_columns', 'my_columns_head');
    function my_columns_head($defaults) {
    $defaults['YOURCOLUMNNAME'] = 'YOURCOLUMNTITLE';
    return $defaults;
    }
    //Add rows data
    add_action( 'manage_YOURPOSTTYPENAME_posts_custom_column' , 'my_custom_column', 10, 2 );
    function my_custom_column($column, $post_id ){
    switch ( $column ) {
    case 'YOURCOLUMNNAME':
    echo get_post_meta( $post_id , 'wpcf-YOURCUSTOMFIELDNAME' , true );
    break;
    }
    }
    
    // Make these columns sortable
    function sortable_columns() {
      return array(
        'YOURCOLUMNNAME'      => 'YOURCOLUMNNAME'
      );
    }
    
    add_filter( "manage_edit-YOURPOSTTYPENAME_sortable_columns", "sortable_columns" );

    It would also be nice to be able to filter these fields from the drop-down menu above the post list. However, this will do for now..

    Please, if anyone involved in developing this plugin is reading this, a lot of people would appreciate this feature included. Thank you.

    https://www.ads-software.com/plugins/types/

Viewing 3 replies - 1 through 3 (of 3 total)
Viewing 3 replies - 1 through 3 (of 3 total)
  • The topic ‘View/sort by custom field in admin post list’ is closed to new replies.