Support Forum
Support › MB Relationships › Relationship setup (following schema.org and Google rich snippets)
Final result should be a proper "Events" page setup.
In schema.org there are types that I need:
- Person
- Organization
- Events
Google rich snippets demands per each event a
- "performer" (a person) and
- an "organizer" (person or organization).
What I did in Meta Box:
- For each schema.org type, I set up a CPT in Meta Box.
- For "Person" I created a taxonomy "activity": performer, organizer.
- I created reciprocal relationships between Events-Person and Events-Organization.
Now, I'm a little bit stucked with the dual-sided activity that a person can have (performer and/or organizer).
Question 1) Should/can I create two custom fields for organizer: organizer_person, organizer_organisation? Usually one will be empty. And on the frontend the empty one will not be displayed?
Question 2a) I don't want to set up all performers, organizers that will ever appear as a separate post. For "one-timers", I'd like to just enter their names into a text field. On top of the relationship fields, should/can I create another text field for the event editor that asks for "performer (manually introduced)" and "organizer (manually introduced)"?
Question 2b) What is the best solution for the front end to display the "performer" data? At least one field has an entry (relationship, manual field), the one without entry won't be displayed? How to combine the data output if there is a performer from a relationship and another one or more from the manual text field?
Hello,
If you don't want to sort or filter the post (person) by performer or organizer, just output the value, you can use the custom field instead of the taxonomy. Please read more in this article https://metabox.io/custom-fields-vs-custom-taxonomies/
Hello 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?
Hello,
Follow the GenerateBlocks Query Loop documenation, you can use the filter hook generateblocks_query_loop_args
to add a custom argument to display the related posts. For example:
add_filter( 'generateblocks_query_loop_args', function( $query_args, $attributes ) {
// apply filter if loop has class: metabox-related-posts
if (! is_admin() && ! empty( $attributes['className'] ) && strpos( $attributes['className'], 'metabox-related-posts' ) !== false) {
$query_args = array_merge( $query_args, array(
'relationship' => [
'id' => 'posts_to_pages',
'from' => get_the_ID(), // You can pass object ID or full object
],
));
}
return $query_args;
}, 10, 2 );
I recommend contacting GenerateBlocks support for further assistance. And read more about query in the documentation
https://docs.metabox.io/extensions/mb-relationships/#getting-connected-items
https://docs.generateblocks.com/article/order-query-loop-by-custom-field/