Home › Forums › Calendar Products › Events Calendar PRO › tribe_events returned when another post_type is specified
- This topic has 6 replies, 2 voices, and was last updated 9 years, 5 months ago by Geoff.
-
AuthorPosts
-
October 24, 2014 at 8:21 am #832534OliverParticipant
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’),
)
)
);October 24, 2014 at 8:31 am #832567GeoffMemberHi 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!
GeoffOctober 24, 2014 at 8:44 am #832596OliverParticipantAch! 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.
October 24, 2014 at 9:17 am #832654GeoffMemberHi 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!
GeoffOctober 27, 2014 at 6:53 am #840429OliverParticipantHi 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.
October 27, 2014 at 8:12 am #840671GeoffMemberHi 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,
GeoffNovember 3, 2014 at 9:26 am #858171GeoffMemberHey 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 -
AuthorPosts
- The topic ‘tribe_events returned when another post_type is specified’ is closed to new replies.