Custom Fields
Support MB Admin Columns Define filterable and/or sortable admin columns in extened class

  • Creator
  • #27937
    Resolved Jugibur


    if I see correctly, I can't use fields in the admin columns that are inside a group field. At least the output remains empty for me.

    But that isnt't a big problem for me, because I have build a Plugin for extending a Custom Post Type following your example in the documentation:

    class Prefix_Custom_Admin_Columns extends \MBAC\Post {
        public function columns( $columns ) {
            $columns  = parent::columns( $columns );
            $position = '';
            $target   = '';
            $this->add( $columns, 'column_id', 'Column Title', $position, $target );
            // Add more if you want
            return $columns;
        public function show( $column, $post_id ) {
            switch ( $column ) {
                case 'column_id':
                    echo 'Column content';
                // More columns

    Question is, how can I define columns that should be filterable and/or sortable?

    I tried to understand your code in the plugin classes and saw some methods, but I couldn't figured it out how to do a setup for such a column.

    Thanks in advance for any hint

Viewing 2 replies - 1 through 2 (of 2 total)
  • Author
  • #27955
    Long Nguyen


    Thank you for reaching out.

    The custom admin columns do not support sorting by field value due to we don't know what's data type you add to the column. You can override the function sort() like show() to handle the query.


    Thanks for replay and the code, I will give it a try!

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