tribe_events returned when another post_type is specified

Home Forums Calendar Products Events Calendar PRO tribe_events returned when another post_type is specified

Viewing 7 posts - 1 through 7 (of 7 total)
  • Author
    Posts
  • #832534
    Oliver
    Participant

    I’m very happy generally with The Events Calendar but I have a function which uses post tags to displays a list of related posts. However, in the following example, if I add the tag “Films” to a “tribe_events” custom post it is still returned by the query, even though I’m specifying that only “resource” custom posts should be returned. Is this a bug with the plugin?

    $args = array(
    ‘post_type’ => array(‘resource’),
    ‘tax_query’ => array(
    array(
    ‘taxonomy’ => ‘post_tag’,
    ‘terms’ => array(‘Films’, ‘TV Shows’),
    )
    )
    );

    #832567
    Geoff
    Member

    Hi there Oliver, welcome to the forums. 🙂

    Ah, I see that you’re using different versions of The Events Calendar (3.2) and The Events Calendar PRO (3.8.1). These types of errors can definitely happen when the versions are our of sync.

    Try upgrading PRO to 3.8.1 to see if that clears it up. You can grab it by logging into this site and heading over to the Downloads page.

    Does that help answer your question? Please let me know. 🙂

    Cheers!
    Geoff

    #832596
    Oliver
    Participant

    Ach! Yes I worked that out in the time it took you to reply. My REAL issue is the one I’ve just explained above. Sorry for cross posting but I thought I’d better get Events Calendar Pro correctly installed before I explained my real problem.

    #832654
    Geoff
    Member

    Hi there Oliver! I’m glad updating the core plugin resolved the issue.

    In general, we try to keep our forum topics to one thread per issue (and leave them unedited) so others can more easily find answers to similar issues. Please keep that in mind for the future, but let’s see if we can tackle the issue with your query. 🙂

    Events posts can be queried either by using the tribe_get_events() function or the default WordPress get_posts(). In this case, it sounds like get_posts() is your best bet since you want to exclude Events from the query and only show Resources.

    That would look something closer to this, though you may need to massage it for your specific situation:

    $args = array(
    'posts_type' => 'resource',
    'terms' => array('films', 'tv_shows');

    I hope this helps point you in the right direction. 🙂

    Cheers!
    Geoff

    #840429
    Oliver
    Participant

    Hi Geoff, that’s pretty much what I’m doing already. When WordPress finds a tribe_event with a matching post_tag it decides to ignore the post_type argument – this is not an issue with any other custom post_type.

    #840671
    Geoff
    Member

    Hi there, Oliver! Thanks for following up.

    Events posts are registered as a custom post type, so it would be possible to set your query up to specific exclude them specifically within the get_posts function using the exclude_from_search option. There’s more on this in the WordPress Codex.

    One other thing to watch for is resetting a query before starting a new one. Running multiple loops without resetting them can create a situation where post types are mixed in both queries. There’s more on running multiple loops in the Codex you may want to check out.

    I hope this helps!

    Cheers,
    Geoff

    #858171
    Geoff
    Member

    Hey there, Oliver! It’s been a while so I’m going to go ahead and close this thread. If we can help with anything else, though, please don’t hesitate to create new a new thread and we’d be happy to help. 🙂

    Cheers!
    Geoff

Viewing 7 posts - 1 through 7 (of 7 total)
  • The topic ‘tribe_events returned when another post_type is specified’ is closed to new replies.