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

  • Hi John — I hope you had a nice, relaxing and well-deserved weekend.

    $query->get( ‘organizer’ ) is returning nothing because it is not set. It appears that this has been changed to tribe_organizer.

    You appear to be correct. With the code above in place, the die function is never returned. Once changed to get( 'tribe_organizer' ), “query var set” is returned.

    So I gave this a look:

    if ($query->get('tribe_organizer')) {
      var_dump($query->get('tribe_organizer')); echo '<br />';
    }

    Which returned:
    string(14) "alex-greenbaum"

    So —

    You need the post ID for this organizer and not the name.

    Given what you’ve explained to be what we’re looking for, would either of these solutions, if nothing else, be helpful starting points?

    Solution 1 (based on this native Tribe function tribe_get_organizer_ids)

    // search the ID of organizer
    $organizers = tribe_get_organizer_ids($id);
    
    // retrieve name of organizer
    // will create an events loop tribe_get_events
    $orgName = array();
    foreach($organizers as $organizerId) {
      $orgName[] = tribe_get_organizer($organizerId);
    }

    And, another here: Solution 2

    Additionally, all of the native Tribe organizer-related functions, straight from their documentation here.

    Tell me more about this query we’re trying to modify, it is a sub query? The information for the organizer has already been shown and now you are trying to show the events that they are organizing?

    That is correct. I am trying to display all of the events for which the organizer has been set as an organizer/speaker.

    The “Organizer” page, as it is natively called, is said to be a custom taxonomy.

    Bear with me here, because it may (almost certainly will) get a little confusing. I have changed the label of this post-type (or custom taxonomy?) to “Speakers | Organizers”. With some template customization, and the help of ACF Pro, from the single event edit screen, I use the native meta section to select what is being output under a “Speakers” header in the meta section on the front end, and a separate ACF Pro relational object field to select what is being output under an “Organizers” header in the meta section on the front end. Both the native meta object selection field and the ACF Pro selection field are pulling from the same pool of “Speakers | Organizers.”

    That’s all working as intended.

    By default, the individual Speaker | Organizers pages then display all upcoming events that the Speaker | Organizer is tied to. For a while, that solution I posted in the first post of this thread, ensured that the upcoming event was posted on the individual’s Speaker | Organizer, regardless of whether they were attached via the native tribe meta field or the ACF Pro relational field. Now, however, the upcoming events loop found on the individual Speaker | Organizer page is only pulling in that respective Speaker | Organizer’s upcoming event if it were set via the native meta field (while failing to recognize it as an upcoming event if set via the ACF Pro relational field).