Limit Categories pulled in Events Query

Home Forums Calendar Products Events Calendar PRO Limit Categories pulled in Events Query

Viewing 8 posts - 1 through 8 (of 8 total)
  • Author
    Posts
  • #14825
    John
    Participant

    If you check out http://aia.imagebox.com you will see we have a section on the homepage which has 3 tabs on “Columns, “News”, “Events” Within the events tab we have it coded so that it pulls an excerpt of an event in the main column and in the sidecolumn of the tab it has additional events.

    My question is 2 fold. First in the left column of this tab we want to limit this section to exclude certain categories. Basically we are using this section to “feature” an event. We will have both company sponsored events and public events. We only want our company sponsored events to ever show up in this larger block in column 1. Currently we are using the following code snippet to do this in our theme:

    http://pastebin.com/UJbDAneh

    Is there any other paramaters to inject at ‘eventDisplay’=>’all’,
    Can we limit this to only category id #’s which contain company sponsored events?

    The second part to my question is:
    How can we limit this to only pull an upcoming event. As you can see now its pulling an event from January. Obviously that has passed an shouldn’t be shown on the homepage an upcoming event. I realize normally WordPress just pulls from the DB based on POST DATE and not the event date.
    This same question applies to the upcoming events in the right column of this tab. They also should be limited to events in the future. Right now its showing events from Feb 1 and Feb 21. The Feb 1 shouldn’t be showing since its past. Is there some sort of query I can run to pull upcoming events only and do it to sort by EVENT date instead of POST date?

    #14839
    Rob
    Member

    Hey John. Thanks for the note here. Let me see if our dev Jonah has any suggestions as to your first point; while we can’t guarantee anything since this is a customization issue, we’ll offer up what we can.

    For #2: have you checked to see whether the material in our template tag documentation (https://theeventscalendar.com/support/documentation/) points you in the right direction? If not, or if you’ve already looked there, let me know and we can advise accordingly.

    #14844
    John
    Participant

    Rob –

    Thanks I would appreciate the guidance of Jonah. It seems like such a simple thing to do since you can do it with wordpress already if you want to loop through posts if and only if they are in certain categories.

    AS to the 2nd part of my question: I found tribe_is_upcoming() in the documentation but I am not exactly sure of how to use this. I presume something like this:

    http://pastebin.com/0QuTAxzY

    but I don’t what array items I can pass to the function tribe_is_upcoming()

    #14849
    John
    Participant

    I did some digging through the forums and found that I can place upcoming into the event post array – http://pastebin.com/CgZLuLvh

    Which is great because now the left “featured” event is displaying the next upcoming event, but now I need to know if there is a way to limit the category(ies) it pulls from.

    I tried using ‘category__in’ => array( 98, 99 )

    2 of the categories I want to be included in the loop, but that didn’t work. It just returns an empty array – http://pastebin.com/gPHefYf4

    #14852
    Rob
    Member

    Thanks for confirming, John. What you’ve offered up here as to the second point also makes sense. I’ll have Jonah take a look at both when he hits the forums this morning.

    #14859
    Jonah
    Participant

    Hi John,

    It sounds like you partially figured out the first part of your question. Using ‘upcoming’ for ‘eventDisplay’ will only pull in upcoming events. Other valid options here are: ‘past’, ‘day’, ‘all’, ‘month’.

    As for querying by specific category, you can definitely do this. Look at the 2nd to last example in the doco here: https://theeventscalendar.com/support/documentation/the-events-calendar-template-tags-general-functions/#functiontribe_get_events

    We use taxonomies for categories so that’s why category_in was not working for you.

    I hope that helps but let me know if you need anything else.

    #14868
    John
    Participant

    I feel as thought i am almost there, but not quite.

    Here is my new code: http://pastebin.com/sfgpkc9X

    I currently have 3 event categories right now. Their slugs are:

    yaf
    cran
    non-aia-events

    As you can see in my code its set to just pull 1 event from the cran event category. However with that code in my homepage template it is displaying nothing even though their is 1 event within the cran event category which occurs on February 28th, 2012.

    Also, if I want to specify multiple event categories, would I just separate the slugs by commas? ie: ‘terms’ => ‘yaf,cran’

    #14871
    Jonah
    Participant

    Hey John,

    You’re close. tax_query is a WordPress function parameter and you can find out more about what it accepts here: http://codex.wordpress.org/Class_Reference/WP_Query#Taxonomy_Parameters

    Try setting field to id and using an array for multiple “category” id’s and an operator like so (change NOT IN to IN):

    ‘field’ => ‘id’,
    ‘terms’ => array( 103, 115, 206 ),
    ‘operator’ => ‘NOT IN’

Viewing 8 posts - 1 through 8 (of 8 total)
  • The topic ‘Limit Categories pulled in Events Query’ is closed to new replies.