Support Forum
We are building a way to display the topics our team members present at speaking events.
I have Custom Post Types for Team Members (team), Topics (topic), and Events (events)
with the following Relationships:
One view of the data will be to display the Topics of an individual Team Member on the Single Team page.
I have the view working except for one line where I want to display the related topic_datetime followed by the related event.name.
The view displays everything correctly except for the event.name. Can you tell me what I am doing wrong?
View: team-member-topic-view
https://pastebin.com/C57JiN93
The problem is in the second part of this div: <div class="topic-date-and-event-name">
I've tried to annotate a screenshot of this view's output and where the problem lies. I can give you access to the staging site if that would help.
https://share.cleanshot.com/s3gJjfz0
I did see in this support post a solution for traversing multiple related CPTs: https://support.metabox.io/topic/traversing-multiple-related-cpts/
I updated the view code for my custom post type configuration, but it returned fatal query normalizer errors.
https://share.cleanshot.com/Hr6wjQQp
Single Team Member Topics view:
https://pastebin.com/f3WD9DXN
Any help you can give will be appreciated.
Hello,
Can you please also share the settings of 2 relationships?
- Team to Topic (team-to-topic)
- Topic to Event (topic-to-event)
I check this View code https://pastebin.com/f3WD9DXN
but don't see any issue when outputting topic
and event
posts.
Topic to Team Relationship
https://pastebin.com/yg9iBdYw
Topic to Event Relationship
https://pastebin.com/5wWAL2Wv
I check this View code https://pastebin.com/f3WD9DXN
but don't see any issue when outputting topic and event posts.
Can I give you access to the staging site where I am seeing the fatal errors?
Hello,
The relationship ID in the query args is wrong. This is the relationship settings:
function your_prefix_function_name() {
MB_Relationships_API::register( [
'id' => 'event-to-topic',
this is the query args
{% set topic_args = { relationship: { id: 'relationship-team-to-topic', from: post.ID }, nopaging: true, post_type: 'topic' } %}
it should be event-to-topic
, not relationship-team-to-topic
. Where do you get this ID relationship-team-to-topic
?
Here is the updated query args
{% set topic_args = { relationship: { id: 'topic-to-team', to: post.ID }, nopaging: true, post_type: 'topic' } %}
{% set event_args = { relationship: { id: 'event-to-topic', to: topic.ID }, nopaging: true, post_type: 'event' } %}
Let me know if it helps.
Thank you, that helped.
In the View, how do I set an orderby?
I tried:
{% set topic_args = { relationship: { id: 'relationship-team-to-topic', from: post.ID }, nopaging: true, post_type: 'topic', orderby: '{ post.topic_datetime | date( 'Y-m-d H:i' ) }', order: 'ASC' } %}
but it resulted in fatal errors.
Hello,
If you use the variable, you should remove the curly brackets and single quote from the query arg:
{% set topic_args = {
relationship: { id: 'relationship-team-to-topic', from: post.ID },
nopaging: true,
post_type: 'topic',
orderby: post.topic_datetime | date( 'Y-m-d H:i' ),
order: 'ASC' }
%}
That worked great.
Thank you very much for your help.