Support

Account

Home Forums Bug Reports Relationship issue with tribe_events custom post type

Solved

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);
Viewing 8 posts - 1 through 8 (of 8 total)

The topic ‘Relationship issue with tribe_events custom post type’ is closed to new replies.