Home › Forums › Calendar Products › Events Calendar PRO › Events not showing in category
- This topic has 6 replies, 3 voices, and was last updated 8 years, 10 months ago by Support Droid.
-
AuthorPosts
-
December 18, 2013 at 3:36 pm #82607Bastien Bournet-CharrierParticipant
See related thread #post-82363
Hey there,
I’ve asked this question before and got a satisfying answer. However, I just figured out the solution provided might not just fit our needs. Our theme uses widgets to display content from a given category. We’d like to feature the latest event using our theme’s widgets. However, the “Events” category is not populated by TEC posts.
Can you provide me with a custom function to add TEC post-type to our “Events” category?
Regards,
BastienDecember 19, 2013 at 5:35 am #82765BarryMemberHi Bastein,
Just to avoid confusion, when you refer to the “Events” category is this a distinct taxonomy that you have set up, or is it a regular WordPress category called “Events”, or something else?
Thanks!
December 19, 2013 at 9:50 am #82832Bastien Bournet-CharrierParticipantHey Barry,
Thank you for your answer! What I am referring to is a regular WordPress Category called “Events”.
Kind regards,
BastienDecember 19, 2013 at 2:17 pm #82892BarryMemberI’m tending to think the path of least resistance would be to customize (or build an equivalent of) the widget you are using. Essentially though you could use register_taxonomy_for_object_type() to tell WordPress that regular WP categories should also be used for events.
This may or may not be sufficient in itself, depending on how your widget is performing its queries (if it is strictly querying for posts rather than posts of any type it may not by itself do what you want).
I’m also unsure if you mean that you would want this specific category term to be automatically populated whenever you save an event or if you would be manually assigning. The former is definitely possible but would take a bit more legwork.
Ultimately, I think this pushes the bounds of what we can help with, but exploring the WP codex – starting with the function I referenced above – is probably a good way to start here.
December 19, 2013 at 2:24 pm #82895Bastien Bournet-CharrierParticipantHey Barry,
Once again, thank you for your answer. It would be doable that way for sure, but I’d like to stay away from creating a new widget as far as possible.
I had the same issue with another plugin that created posts with a custom taxonomy. I fixed the problem using this custom function :
function id_add_custom_types( $query ){
$project_cat = get_term_by(‘slug’, ‘projects’, ‘category’);
if( $project_cat && $query->is_main_query() && (‘projects’ == $query->query_vars[‘category_name’] || $project_cat->term_id == $query->query_vars[‘cat’]) ) {
$query->set(‘post_type’, array(‘post’,’ignition_product’));
}
}
add_filter( ‘pre_get_posts’, ‘id_add_custom_types’ );Wouldn’t it be possible to use the same solution? Isn’t there a custom taxonomy I could use, something like modern_tribe_event? The code would then be along of lines of :
function tec_add_custom_types( $query ){
$project_cat = get_term_by(‘slug’, ‘events’, ‘category’);
if( $project_cat && $query->is_main_query() && (‘projects’ == $query->query_vars[‘category_name’] || $project_cat->term_id == $query->query_vars[‘cat’]) ) {
$query->set(‘post_type’, array(‘post’,’modern_tribe_event’));
}
}
add_filter( ‘pre_get_posts’, ‘tec_add_custom_types’ );If you can’t help that’s fine, I guess I’ll have to address this concern to our developers. However, I was hoping for a simple solution.
Regards,
BastienDecember 20, 2013 at 7:57 am #83015BarryMemberJust a note first of all that it’s best to share code via Pastebin, Gist or some similar service – right now, unfortunately, the forum doesn’t do a great job of formatting code and indeed can strip elements out (of course we hope to remedy this in the near future) – so we can rarely be sure if we are seeing a complete snippet and it can, additionally, be pretty hard to read.
If what you’ve outlined has worked in the past for you and represents what you are trying to achieve then all I can say is, change the post types/taxonomies appropriately and give it a try! On our side I’m afraid we can’t offer further support for a customization like this and you’d really need to pursue it yourself/in tandem with your developers.
Sorry we can’t offer more – and I’ll now go ahead and close this thread. If there is anything else we can help with please don’t hesitate to create a new thread or threads as needed.
Thanks – and good luck!
July 7, 2015 at 6:30 am #982839Support DroidKeymasterThis topic has not been active for quite some time and will now be closed.
If you still need assistance please simply open a new topic (linking to this one if necessary)
and one of the team will be only too happy to help. -
AuthorPosts
- The topic ‘Events not showing in category’ is closed to new replies.