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

  • This is where it really starts going down a rabbit hole. The function tribe_organizer_upcoming_events() doesn’t really do anything. What I would really need is the function that actually constructs and runs the WP_Query. This function calls tribe_include_view_list() and more than likely that function calls other functions and filters before the query is constructed an run somewhere.

    And I really wouldn’t be able to construct a custom query based on the other information I have. Plus, we really don’t care about the organizer because you want to swap out anything it’s doing there with the value of an acf relationship field.

    If I had access to 100% of the code for this plugin so that I can follow what’s going on where and keep things organized and several hours I’m sure I could find a solution. But trying to do this here it’s confusing, and I don’t even know what to ask you for or tell you what to look for.

    So I’m going to circle back to something we looked at before. Looking at the query that’s being done where you want to make the change. Looking back at the WP_Qeury objects that you posted, none of them look like the query that you actually want to modify because none of them include any query parameter that would filter the posts by an organizer. So what you need to do is to see all of the queries being done and then figure out what one needs to be altered.

    How to you do this.

    
    add_action('tribe_events_pre_get_posts', 'log_queries');
    function log_queries($query) {
      ob_start();
      print_r($query);
      error_log(ob_get_clean());
    }
    

    What will this do? This will write every query done on a page load to your php error log. You load the page were you want to modify the query. then you download the error log and crawl though it until you locate the query object that is actually querying events for a specific organizer. If you can figure that out then you’ll have a better idea what you need to do to detect which query to alter and what you need to do to alter it.