Skip to content

Instantly share code, notes, and snippets.

Embed
What would you like to do?
Advanced Custom Fields -Relationship & The Event Calendar past events
<?php
add_filter( 'acf/fields/relationship/query/key=field_59006ee8b9a7b', 'bea_acf_relationship' ), 10, 3 );
/**
*
* Display all events in Relationship field ( future, past )
*
* @param $args
* @param $field
* @param $object_id
*
* @return mixed
* @author Alexandre Sadowski
*/
function bea_acf_relationship( $args, $field, $object_id ) {
if ( ! class_exists( 'Tribe__Events__Query' ) ) {
return $args;
}
remove_action( 'pre_get_posts', array( 'Tribe__Events__Query', 'pre_get_posts' ), 50 );
return $args;
}
@manoj382

This comment has been minimized.

Copy link

@manoj382 manoj382 commented Jul 24, 2018

For anybody trying to use this snippet, there is an extra closing parenthesis on line 2. It should be:

add_filter( 'acf/fields/relationship/query/key=field_59006ee8b9a7b', 'bea_acf_relationship', 10, 3 );

https://www.advancedcustomfields.com/resources/acf-fields-relationship-query/#usage

@knijia

This comment has been minimized.

Copy link

@knijia knijia commented May 22, 2019

Hi, this is exactly what i was searching for, but where to put this code ? Theme's functions.php, plugin's acf.php ? Thanks ;-)

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment