Events not showing in category

Home Forums Calendar Products Events Calendar PRO Events not showing in category

Viewing 7 posts - 1 through 7 (of 7 total)
  • Author
    Posts
  • #82607

    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,
    Bastien

    #82765
    Barry
    Member

    Hi 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!

    #82832

    Hey Barry,

    Thank you for your answer! What I am referring to is a regular WordPress Category called “Events”.

    Kind regards,
    Bastien

    #82892
    Barry
    Member

    I’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.

    #82895

    Hey 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,
    Bastien

    #83015
    Barry
    Member

    Just 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!

    #982839
    Support Droid
    Keymaster

    This 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.

Viewing 7 posts - 1 through 7 (of 7 total)
  • The topic ‘Events not showing in category’ is closed to new replies.