Relationship Admin Column not showing data

Support MB Relationships Relationship Admin Column not showing dataResolved

Viewing 11 posts - 1 through 11 (of 11 total)
  • Author
    Posts
  • #11475
    Max ElmanMax Elman
    Participant

    Using the below code, and column headers are created, but no data is showing in the columns.

    Screenshot of column: https://cl.ly/7cbffe5d6bc1

    Screenshot of relationship: https://cl.ly/ac94e6b15fa2

    add_action( 'mb_relationships_init', function() {
        
        // attorneys to events
        MB_Relationships_API::register( array(
            'id'   => 'attorney_to_event',
           
            'from' => array(
                'post_type'   => 'attorney',
                'meta_box'    => array(
                    'title'       => 'Linked Events',
                ),
            ),
            'to' => array(
                'post_type'   => 'event',
                
                'admin_column' => array(
                    'position'   => 'after title',
                    'title'      => 'Speakers',
                ),
                
                'meta_box'    => array(
                    'title'       => 'Linked Attorney',
                ),
            ),
        ) );
    } );
    #11478
    Anh TranAnh Tran
    Keymaster

    Hi Max,

    Your code seems to be correct. Would you mind sending me a temporary admin account to check?

    #11482
    Max ElmanMax Elman
    Participant

    Sent, thanks.

    #11483
    Anh TranAnh Tran
    Keymaster

    Just fixed it on your website and on Github. It's a bug caused by a previous commit for post_type=any.

    Thanks for letting me know the bug!

    #11491
    Max ElmanMax Elman
    Participant

    Thank you! I was going a little crazy troubleshooting that myself.

    Two related questions:

    1) Why is the code within relationships 'admin_column' and within the full admin columns extension 'admin_columns'? (Difference in 's')

    2) Are the full admin column parameters supported within relationships? (before, after, sort, searchable, filterable)

    #11494
    Anh TranAnh Tran
    Keymaster

    Hi Max,

    1) When we work on admin column for relationship at first, we thought it's a single relationship column, so we use singular form. The Admin Columns extension was made for multiple fields, so it's plural.

    2) For relationships: it's not supported. Because the relationships are list of connections and will be unclear when we put something like sorting, search for those connections.

    #15033
    mzykinmzykin
    Participant

    Hey guys,

    Just curious what the fix was? I'm running into the same exact issue.

    Running MB version 4.18.2 and MB Relationships 1.6.0.

    Cheers,
    Mary-Ann

    #15048
    Anh TranAnh Tran
    Keymaster

    The fix was here. It's available in the latest version.

    #15075
    mzykinmzykin
    Participant

    Hi Anh,

    Thanks for the response! I took a look at the link and it looks like there's been some changes since that commit.

    I downloaded the latest stable release (1.6.0) and am still running into the issue. It looks like file referenced above (inc/class-mb-relationships-relationship.php) no longer exists, and has been modified into inc/relationship/admin-columns.php, which is where I think the issue is coming from.

    #15082
    Anh TranAnh Tran
    Keymaster

    Yes, the new code has been moved to admin-columns.php file but it's still the same. The fix was changing from get_posts to WP_Query.

    I've just tested again with the code in the first reply and it seems to work fine. Can you post your code?

    #15106
    mzykinmzykin
    Participant

    Hey Anh,

    Sure thing, here's my code:

    add_action( 'mb_relationships_init', function() {
        MB_Relationships_API::register( array(
            'id'   => 'groups_to_group_sessions',
            'from' => array(
                'object_type' => 'post',
                'post_type' => 'group',
                'meta_box' => array(
                    'title' => 'Group Sessions'
                ),
                'admin_column' => array(
                    'position' => 'before date',
                    'title' => 'Group Sessions'
                )
            ),
            'to'   => array(
                'object_type' => 'post',
                'post_type' => 'group-session',
                'meta_box' => array(
                    'title' => 'Groups'
                ),
                'admin_column' => array(
                    'position' => 'after title',
                    'title' => 'Groups'
                )
            )
        ) );
    
        MB_Relationships_API::register( array(
            'id'   => 'user_to_group',
            'from' => array(
                'object_type' => 'user',
                'admin_column' => array(
                    'title' => 'Groups'
                )
            ),
            'to'   => array(
                'post_type' => 'group'
            )
        ) );
    } );

    The relationships are being created in the database and the admin columns themselves are appearing, but columns are blank and don't show the connected posts.

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