Custom Fields
Re-Envisioned
Support MB Admin Columns No Admin Columns Showing

  • Creator
    Topic
  • #15302
    Resolved SLG Marketing
    Participant

    I’ve tried adding some admin columns to a CPT but they won’t output at all. What am I doing wrong?

     public function generateMetaBox($meta_boxes){
            // General
            $meta_boxes[]=array(
                'id'=>'general',
                'title'=>'General Person Settings',
                'post_types' => 'people',
                'context'    => 'normal',
                'priority'   => 'high',
                'fields'=> array(
                    array(
                        'name'  =>  'Job Title',
                        'id'    =>  'people_jobtitle',
                        'type'  =>  'text',
                        'desc'=>'TODO: help text',
                        'admin_columns' => 'after title'
                    ),
                    array(
                        'name'=>'Year Joined',
                        'id'=>'people_yearjoined',
                        'desc'=>'TODO: help text',
                        'type'=>'number',
                        'min'   =>  1980,
                        'max'   =>  date('Y'),
                        'admin_columns' => true,
                    ),
                )
            );
    
            return $meta_boxes;
        }
Viewing 10 replies - 1 through 10 (of 13 total)
  • Author
    Replies
  • #15307
    Anh Tran
    Keymaster

    I know this is a stupid question, but have you activated the MB Admin Columns extension? Some users forget to do this.

    #15311
    SLG Marketing
    Participant

    It’s being loaded as an MU plugin. I’ll try moving it to the normal plugin folder.

    #15312
    SLG Marketing
    Participant

    I just tried it as a normal plugin, I am getting the same issue.

    #15406
    SLG Marketing
    Participant

    Is there any further debug information you need on this?

    #18062

    Did anyone ever find anything on this issue?
    I’m having similar issues at the moment, and it looks like it’s related to the id in the main array (‘general’ in this example).
    On my setup it seems that only fields from an array where the ‘id’ is equal to the post-type slug are presented in the admin columns. But this is something recent, because I know quite certain that the field showed up a few months ago.

    Any thoughts?

    Best,

    AJ

    #18064
    SLG Marketing
    Participant

    Hi

    I didn’t get any feedback from the devs which was a little disappointing.

    My own research indicates that it is caused by the order that custom post types are loaded. I haven’t looked at this for ages so I’ll spin up a test site and do some more digging.

    #18066
    SLG Marketing
    Participant

    I have figured this out, you need to have an execution order greater than the default of 10 on the metabox rwmb_meta_boxes filter.

    add_filter( 'rwmb_meta_boxes', [$this,'generateMetaBox']);
    

    Becomes

    add_filter( 'rwmb_meta_boxes', [$this,'generateMetaBox'],20);
    
    #18091
    Anh Tran
    Keymaster

    Hi guys, sorry for not following up the thread. I think the solution above should work. Please let me know if you have any trouble with that.

    #18177

    Hi,

    the order definitely does influence the appearance of the admin columns, but only the highest one remains visible. Our website had multiple calls to
    add_filter( 'rwmb_meta_boxes', function($metabox){$metabox[]=[....]}, 20);
    (one for each post-type)

    If I add both
    add_filter( 'rwmb_meta_boxes', function($metabox){$metabox[]=[....]}, 20);
    and
    add_filter( 'rwmb_meta_boxes', function($metabox){$metabox[]=[....]}, 21);
    all fields function properly, except the admin columns: only the admin columns in the highest one do appear.

    #18179
    SLG Marketing
    Participant

    What order are you loading in your CPTs?

    We load ours from MU plugins which has a higher execution order than ones in the theme or the normal plugin folder.

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