Custom Fields
Re-Envisioned
Support MB Relationships Relationships have stopped saving

  • Creator
    Topic
  • #19067
    Resolved nerm
    Participant

    The relationships no longer save, I uploaded an older version AIO I had on file from March last year to test and all worked fine. I was prompted to update the plugin and once updated it stopped working again

Viewing 3 replies - 1 through 3 (of 3 total)
  • Author
    Replies
  • #19069
    Long Nguyen
    Moderator

    Hi,

    Thank you for contacting us.

    If you are using the latest version of Meta Box v5.2.8 and Meta Box AIO v1.11.2, please share the code that you are using to create the relationship.

    Below is the sample code creates the relationship between 2 post types Author and Book that I’m using and it works as well as save the data.

    add_action( 'mb_relationships_init', function() {
        // Add CPT Relationship between Authors + Books
        MB_Relationships_API::register( [
            'id'   => 'books_to_book_author',
            'from' => [
                'object_type' => 'post',
                'post_type' => 'book',
                'meta_box'    => [
                    'title' => 'Author',
                    'priority' => 'high'
                ],
            ],
            'to'   => [
                'object_type' => 'post',
                'post_type' => 'author',
                'meta_box'    => [
                    'title' => 'Books by this author',
                ],
            ]
        ] );
    } );
    #19070
    nerm
    Participant
    add_action( 'mb_relationships_init', function () {
        MB_Relationships_API::register( array(
            'id'   => 'products_to_products',
            'from' => array(
                'object_type' => 'post',
                'post_type'   => array('carburetors', 'distributors','linkage-kits','fuel', 'parts'),
                'meta_box'    => array(
                    'context' => 'normal',
                    'columns' => 3,
                    'title'       => 'Connected to Products',
                    'field_title' => 'Select Product',
                ),
            ),
            'to' => array(
                    'object_type' => 'post',
                    'post_type'   => array('carburetors', 'distributors','linkage-kits','fuel', 'parts'),
                    'meta_box'    => array(
                        'context' => 'normal',
                        'columns' => 3,
                        'title'       => 'Connected from Products',
                        'field_title' => 'Select Products',
                    ),
                ),
            ) );
    } );
    #19084
    Long Nguyen
    Moderator

    Hi,

    The extension only supports one post type for each relationship register, not the array like your code array('carburetors', 'distributors','linkage-kits','fuel', 'parts')

    You can create more relationships for each post type or use the reciprocal to connect all posts
    https://docs.metabox.io/extensions/mb-relationships/#reciprocal-relationships

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