Relationships have stopped saving
Support › MB Relationships › Relationships have stopped savingResolved
- This topic has 3 replies, 2 voices, and was last updated 5 years ago by
Long Nguyen.
-
AuthorPosts
-
April 16, 2020 at 8:09 PM #19067
nerm
ParticipantThe 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
April 16, 2020 at 8:53 PM #19069Long Nguyen
ModeratorHi,
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', ], ] ] ); } );
April 16, 2020 at 8:58 PM #19070nerm
Participantadd_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', ), ), ) ); } );
April 17, 2020 at 8:58 AM #19084Long Nguyen
ModeratorHi,
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 -
AuthorPosts
- You must be logged in to reply to this topic.