Support

Account

Home Forums Front-end Issues Include meta added via relational post object in an existing query function Reply To: Include meta added via relational post object in an existing query function

  • Rather than do that let’s see if we can work out the issue.

    I am assuming that the line in their function

    
    return apply_filters( 'tribe_organizer_upcoming_events', $html );
    

    eventually causes your filter to be run.

    The first thing we need to find out is if your filter is running at all. Do you know that this is the case? If not then

    
    <?php
    
    // Add all events to bio pages
    add_action( 'tribe_events_pre_get_posts', function( &$query ) {
        
        // see if this filter is being called
        echo 'my filter was called'; die;
        
        if ( $query->tribe_is_event_query && $query->get( 'organizer' ) != '' ) {
            // build our own version of the meta query for organizers
            $new_meta_query_term = array(
                array(
                    'key'   => '_EventOrganizerID',
                    'value' => $query->get( 'organizer' ),
                ),
                array(
                    // ACF field
                    'key'     => 'the_organizers',
                    'compare' => 'LIKE',
                    'value'   => '"' . $query->get( 'organizer' ) . '"'
                ),
                'relation' => 'OR'
            );
            $meta_query = $query->get( 'meta_query' );
            foreach( $meta_query as &$meta_query_term ) {
                // replace the meta query term that The Events Calendar made with our new one
                if( isset( $meta_query_term['key'] ) && $meta_query_term['key'] == '_EventOrganizerID' ) {
                    $meta_query_term = $new_meta_query_term;
                    break;
                }
            }
            $query->set( 'meta_query', $meta_query );
        }
    } );