Including Events in Main WP_Query

Home Forums Calendar Products Events Calendar PRO Including Events in Main WP_Query

Viewing 5 posts - 1 through 5 (of 5 total)
  • Author
    Posts
  • #1011300
    Gary
    Participant

    So, I want to include events in my main loop, but ONLY if they’re from one particular organizer.

    This is the query alteration I’ve written, but it’s not working.
    function alter_query_jrr($qry) {
    if ( $qry->is_main_query()) {
    $qry->set(‘post_type’,array(‘tribe_events’,’posts’));
    $qry->set(‘tribe_organizer’,3690);
    }
    }
    add_action(‘pre_get_posts’,’alter_query_jrr’);

    What I want the loop to include is my posts and events from only 1 organizer…
    I searched the pre_get_posts docs and just can’t wrap my head around how I’d format that.

    Thanks in advance for help or direction…

    #1011746
    George
    Participant

    Hey Gary!

    There are two things about your question that, unfortunately, make it a bit hard to answer completely: first is that your question relates to custom coding, for which we don’t technically offer any support, but secondly (and mainly) is that specifying a taxonomy in pre_get_posts() is a bit tricky. It’s possible, but just tricky.

    If you’re familiar with ‘tax_query’ in WordPress’ WP_Query class, then essentially all you’ll be doing is using that same array format of taxonomy rules and applying it to the query. You should be able to use tax_query to write the organizer-filtering rules you would like. If you’re unfamiliar with tax_query, you can read about it in depth in the “Taxonomy Parameters” section of this article here → https://codex.wordpress.org/Class_Reference/WP_Query

    If you’re interested in some code examples and such, there are fortunately many out there for this problem. I found a good one here, for example, if you’re curious → http://wordpress.stackexchange.com/questions/35196/theres-a-way-to-use-query-settax-query-in-pre-get-posts-filter

    I hope all of this information helps!

    — George

    #1011936
    Gary
    Participant

    George,

    Thanks! I wasn’t sure if this would elicit a response as it was custom. So I appreciate the answer and the links.

    I was just having an awful time trying to figure out how to phrase that question in a more general way to pull search results…

    Thanks
    Gary

    #1012490
    Nico
    Member

    Hey Gary,

    George is sick today, but thanks! We’re glad you’re sorted!

    I’ll go ahead and close out this thread, but if you need help with anything else please don’t hesitate to create a new one and we will be happy to assist you.

    Best,
    Nico

    #1013152
    George
    Participant

    Nico was right here, I unfortunately caught a pretty bad cold and wasn’t able to reply in a timely fashion. I’m sorry about that! But I’m glad that my response was somewhat helpful to begin with.

    Thanks for covering for me a bit, too, Nico! 🙂

    Cheers,
    George

Viewing 5 posts - 1 through 5 (of 5 total)
  • The topic ‘Including Events in Main WP_Query’ is closed to new replies.