Last active
August 17, 2022 15:00
Advanced Custom Fields -Relationship & The Event Calendar past events
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
<?php | |
add_filter( 'acf/fields/relationship/query/key=field_59006ee8b9a7b', 'bea_acf_relationship', 10, 3 ); | |
add_filter( 'acf/load_value/name=featured_event', '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; | |
} |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
This seems to work for me.
add_filter('acf/fields/relationship/query/name=featured_event', 'pull_past_events', 10, 3);
add_filter('acf/load_value/name=featured_event', 'pull_past_events', 10, 3);
function pull_past_events($x, $y, $z)
{
if (class_exists('Tribe__Events__Query')) {
remove_action('pre_get_posts', array('Tribe__Events__Query', 'pre_get_posts'), 50);
}
return $x;
}