Forum Replies Created
-
AuthorPosts
-
March 6, 2025 at 1:49 AM in reply to: MB_Relationships_API::each_connected not working, need fix or alternative #47789
Matthias
ParticipantThere is still in March 2025 MB_Relationships_API::each_connected everywhere in the Metabox documentation. What is true?
Matthias
ParticipantI bought Metabox because it seemed quite thorougly developed. But the relationship module is really not properly designed in my opinion. I can set everything up and I can choose even m-n relationships. But accessing and displaying it, is a nightmare.
Especially when I want to use the relationship field as a rich snippet field, it's impossible as the relationship field is somehow only "virtually" available. I can't match the relationship field to a schema field because the relationship is just not available.
July 21, 2023 at 4:48 AM in reply to: Relationship setup (following schema.org and Google rich snippets) #42706Matthias
ParticipantHello Peter,
thanks for your quick reply. I realize that I couldn't express my issue correctly. My custom field and taxonomy setup is fine. The "activity" taxonomy has more items than those two described and is shared between several CPT.
I want to display on an event single page at least one performer and one organizer. And the issue I had in my mind was the mixture of the different sources. E.g. the 'organizer' can be coming from a person (related CPT) and/or an organization (related CPT). And as I don't want to set up all upcoming persons and organizations as posts in the CPT (usually that's the case because they only organize an event once), I thought about adding a text field where I can enter their name.
And for this I will write me a query where all those values from different fields are combined and outputed.
Another issue occured that I can't access relationships properly with GeneratePress and GenerateBlocks. I have really simple relationships like in your tutorials (e.g. instructor for courses, https://docs.metabox.io/tutorials/create-relationships-with-bricks/)
While I can at least get the field value of a relationship with PHP and MB Views on single pages, I can't get anything accessed on archive pages. Although I read the documentation about this point: https://docs.metabox.io/extensions/mb-relationships/#post-archive.
Do you have a tutorial or code example how that works with GenerateBlocks Query Loop or with PHP code on a page-custom.php?
July 18, 2023 at 9:50 PM in reply to: Display Relationship value in GenerateBlocks dynamic data #42636Matthias
ParticipantHi Olivier, I tested the code a little but it seems that when a relationship changes this is not updated in the field. The code would need a specific Meta Box hook to allow to run when a relationship is updated. So, unfortuntately not a real dynamic solution.
July 18, 2023 at 9:43 PM in reply to: Display Relationship value in GenerateBlocks dynamic data #42635Matthias
ParticipantHi Olivier, I had the same problem. GeneratePress Pro and GenerateBlocks Pro don't seem to be the best combination to deal with Meta Box relationships.
I wrote this code for one case where I wanted to add with the dynamic data option by GP and GB a 'person' related to a 'course' on the course single page (that person is in the course context a 'mentor'). This code generates a custom field (my_new_field_name) with a comma separated list of all mentors.
add_action( 'save_post_kurs', 'update_my_new_field_name', 10, 2 );
function update_my_new_field_name( $post_id, $post ) {
if ( defined('DOING_AUTOSAVE') && DOING_AUTOSAVE ) {
return;
}$related_persons = MB_Relationships_API::get_connected([
'id' => 'kurs-person',
'from' => $post_id
]);$mentor_names = [];
foreach ( $related_persons as $person ) {
$mentor_names[] = get_post_meta($person->ID, 'person_name', true);
}update_post_meta( $post_id, 'my_new_field_name', implode( ', ', $mentor_names ) );
} -
AuthorPosts