Support Forum
Support › MB Admin Columns › admin columns not working
Hi,
For some reason I can't get the extension Admin Columns to work. I have the TGM activation in place and seems to work fine.
Other plugins, like Include Exclude, work fine. But Admin Columns does not.
What am I missing?
Hi,
How do you setup the columns to show?
Hey Anh Tran,
As far as I understand I just follow the steps as mentioned in the documentation. What I'v tried so far:
'admin_columns' => true,
'admin_columns' => 'after title',
but also the more advanced ways as described in your documenation.
BTW: The link in the sidebar to 'MB Admin Columns' gives a 404.
Can you post full code of your meta box to check?
PS: I fixed the link in the sidebar. Thanks a lot!
Sure, here we go:
$meta_boxes[] = array(
'title' => __( 'View', 'transport' ),
'post_types' => 'transport',
'fields' => array(
array(
'id' => 'show',
'name' => __( 'Related', 'transport' ),
'type' => 'post',
'post_type' => 'page',
'field_type' => 'checkbox_list',
'admin-columns' => array(
'position' => 'before date',
'title' => __( 'Related', 'transport' ),
'sort' => true,
),
),
),
);
Hi, is that really admin-columns
or you mistyped? It should be admin_columns
, underscore.
Hi, that was a typo. 'admin_columns' does not fix the issue.
Before using this extension, I manually added some columns in the code. Could it be that this couses the trouble?
Hi, I'd like to see what you've done with your custom code. I guess you added or renamed an existing column, so Admin Columns extension couldn't find it to "hook" other columns to.
Hi Anh, this is the custom code I used for showing / hiding custom admin columns:
add_filter( 'manage_transport_posts_columns', 'set_transport_columns' );
function set_transport_columns($columns) {
unset( $columns['date'] );
$columns['show'] = __( 'Koppeling', 'transport' );
$columns['date'] = 'Datum';
set( $columns['date'] );
return $columns;
}
add_action( 'manage_transport_posts_custom_column' , 'transport_columns', 10, 2 );
function transport_columns( $column, $post_id ) {
switch ( $column ) {
case 'show':
echo get_post_meta( $post_id, 'show', true );
break;
}
}
Oh, I see your custom code set a column show
and you have a custom field with the same ID. Then you set that custom field displayed in admin columns, which already exists there. It might be confused. I'd suggest removing your custom code and try again.
Hi,
The issue of the missing admin columns keep occuring. For some unknown reason I can't get the admin columns to show. It works fine on one CPT, but is having trouble on another.
Even when I make a copy of a working CPT, it stops working. I have no idea where to look know.
Can you help me out?
Hi,
Can you post your full code so I can check it out?
Hi,
Hereby the code:
https://ghostbin.com/paste/ssuu2
As said, this code works fine for one CPT, but doesn't for another. Only difference between both are the funcion-titles and post-type names.
Could it be caused because of a earlier error where something is going wrong in building or filling a database table?
What makes me think that is when I rename 'suppliers' to 'sponsors', I get the same issue.