View/sort by custom field in admin post list (4 posts)

  1. Eliot Akira
    Posted 2 years ago #

    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) {
    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 ) {
    echo get_post_meta( $post_id , 'wpcf-YOURCUSTOMFIELDNAME' , true );
    // Make these columns sortable
    function sortable_columns() {
      return array(
    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.


  2. Eliot Akira
    Posted 2 years ago #

    And to delete an unwanted column such as 'date' which might be unnecessary for some custom post types:

    // Delete column
    function my_columns_filter( $columns ) {
        return $columns;
    add_filter( 'manage_edit-YOURPOSTTYPENAME_columns', 'my_columns_filter', 10, 1 );
  3. Eliot Akira
    Posted 2 years ago #

    For anyone who would like to view/sort custom fields in the admin post list, I found this plugin today that would have solved the issue without having to code it:


  4. PowZone
    Posted 1 year ago #

    Thank you Akira!!

    Wonderful post ;)

Topic Closed

This topic has been closed to new replies.

About this Plugin

  • Types
  • Frequently Asked Questions
  • Support Threads
  • Reviews

About this Topic