Home › Forums › Bug Reports › Relationship issue with tribe_events custom post type
Hi,
I’m dealing with a strange issue involving:
– ACF 4.3.9
– Relationship ACField
– The Events Calendar v3.8 (from Tribe)
The issue is that when i choose (in the edit relationship field) to choose only the post type tribe_events, after when i’m in a post and i want to choose one tribe_events entrie, it doesn’t show all the events calendar posts… only shows less than half of the total events calendar entries.
Anyone is also experience this issue?
Best,
ok, i don’t how to fix this, but i at least i discovered the reason. Advanced Custom Field relationship only display the future events not the past events. Please note that this only happen when we choose to display only the post type tribe_events in the relationship field settings. There is a solution for this?
ok i solved this issue. it’s simple and already documented in the plugin relatioship resources. i added a funtion in my funtions.php to add a new parameter to the query:
function my_relationship_query( $args, $field, $post )
{
// add and define tribe events eventDisplay to 'all' since it's predifined only to future.
$args['eventDisplay'] = 'all';
return $args;
}
// acf/fields/relationship/result - filter for every field
add_filter('acf/fields/relationship/query', 'my_relationship_query', 10, 3);
Thank you for sharing. But it doesn’t work for me. Is this really exactly the function you use?
‘past’ does work, but then it doesn’t show the upcoming events. ‘all’ however has no effect..
All right. Figured it out.
Anyone needs to solve this: “all” doesn’t work (anymore?) but “custom” does the job and shows all events (upcoming and past).
Here’s the updated code:
function my_relationship_query( $args, $field, $post )
{
// add and define tribe events eventDisplay to 'all' since it's predifined only to future.
$args['eventDisplay'] = 'all';
return $args;
}
// acf/fields/relationship/result - filter for every field
add_filter('acf/fields/relationship/query', 'my_relationship_query', 10, 3);
Hi,
I’m using the latest from @florian-rosenbauer. I’ve tried it as it is changing the eventDisplay
argument. And also start-date
. But the filter isn’t working.
Does anyone know if something has changed with ACF or Event Calendar?
Do I need to call the filter differently if calling from a plugin?
this does not work for me.
acf/fields/relationship/query
seems only have effect on select list, not on value list
my already tribe_events linked objects are not well displayed if they are in past.
this is due to the admin
context set in eventDisplay
wpQuery argument.
My solution was to change eventDisplay
directly on pre_get_post
filter like described bellow :
function load_all_relational_events( $query )
{
if (is_admin() && $query->tribe_is_event) {
$query-/set('eventDisplay', 'all');
}
}
add_filter('pre_get_posts', 'load_all_relational_events');
hoping will help π
It sadly did not work for me but I tried $args['eventDisplay'] = 'custom';
and it works now π
My final code:
function my_relationship_query( $args, $field, $post )
{
// add and define tribe events eventDisplay to 'all' since it's predifined only to future.
$args['eventDisplay'] = 'custom';
return $args;
}
// acf/fields/relationship/result - filter for every field
add_filter('acf/fields/relationship/query', 'my_relationship_query', 10, 3);
You must be logged in to reply to this topic.
Welcome to the Advanced Custom Fields community forum.
Browse through ideas, snippets of code, questions and answers between fellow ACF users
Helping others is a great way to earn karma, gain badges and help ACF development!
Weβre reaching out to our multilingual users to ask for help in translating ACF 6.1. Help make sure the latest features are available in your language here: https://t.co/TkEc2Exd6U
— Advanced Custom Fields (@wp_acf) May 22, 2023
© 2023 Advanced Custom Fields.
We use cookies to offer you a better browsing experience, analyze site traffic and personalize content. Read about how we use cookies and how you can control them in our Cookie Policy. If you continue to use this site, you consent to our use of cookies.