Custom Fields
Re-Envisioned
Support MB Admin Columns admin columns not working

This topic contains 12 replies, has 2 voices, and was last updated by  stijlXpres 7 months, 1 week ago.

  • Creator
    Topic
  • #6337

    stijlXpres
    Participant

    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?

Viewing 10 replies - 1 through 10 (of 12 total)
  • Author
    Replies
  • #6339

    Anh Tran
    Keymaster

    Hi,

    How do you setup the columns to show?

    #6356

    stijlXpres
    Participant

    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.

    #6358

    Anh Tran
    Keymaster

    Can you post full code of your meta box to check?

    PS: I fixed the link in the sidebar. Thanks a lot!

    #6359

    stijlXpres
    Participant

    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,
            ),
          ),
        ),
      );
    #6361

    Anh Tran
    Keymaster

    Hi, is that really admin-columns or you mistyped? It should be admin_columns, underscore.

    #6365

    stijlXpres
    Participant

    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?

    #6380

    Anh Tran
    Keymaster

    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.

    #6383

    stijlXpres
    Participant

    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;
    	}
    }
    #6386

    Anh Tran
    Keymaster

    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.

    #10522

    stijlXpres
    Participant

    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?

Viewing 10 replies - 1 through 10 (of 12 total)

You must be logged in to reply to this topic.