Exclude Events Tags From Related Events Output

Home Forums Calendar Products Events Calendar PRO Exclude Events Tags From Related Events Output

Viewing 6 posts - 1 through 6 (of 6 total)
  • Author
    Posts
  • #970830
    Christopher
    Participant

    Hi there,

    I need my related events output to show events with the same categories only. I would like to exclude the event tags from this output on the event pages.

    I searched far and wide for a solutions but came up with nothing. Unfortunately, all my events currently in the system have the same tag, which is “2015/16 Season.

    I believe thats why I am seeing the same related events on every event posts. This is not desirable.

    Can you please provide me with the code to exclude Event Tags on the Related Events Output?

    Thank,
    Chris

    #971061
    Josh
    Participant

    Hey Chris,

    Thanks for reaching out to us!

    The related events on the event template are built using the “tribe_get_related_posts()” function. Within this function is also the ability to filter the output using a filter of the same name (tribe_get_related_posts). Looking at the source file for direction, you could use this filter to remove the tags from the array and return just posts related by category.

    Let me know if this helps.

    Thanks!

    #971644
    Christopher
    Participant

    Hi Josh,

    Thanks, yes that helped me. I removed the code below from this file:

    events-calendar-pro/public/template-tags/general.php

    if ( $tags ) {

    $args[‘tax_query’][] = array( ‘taxonomy’ => ‘post_tag’, ‘field’ => ‘id’, ‘terms’ => $tags );

    }

    It did the trick, but this is not ideal because I’m not doing an override here. I’ve edited the file directly.

    I guess my next question is there a way to override this file? I couldn’t find an answer to this in your documentation.

    Thanks,
    Chris

    #972698
    Josh
    Participant

    Hey Chris,

    No problem, try adding the following to your theme’s functions.php file https://gist.github.com/BeardedGinger/329f48f285fb6183b94f to filter out the inclusion of tags from the query without having to modify the core plugin files.

    Let me know if this helps.

    Thanks!

    #984435
    Christopher
    Participant

    Hi Josh,

    Thanks, yes this is exactly what I needed!

    Cheers,
    Chris

    #984514
    Josh
    Participant

    Hey Christopher,

    Awesome! Happy to help.

    I’ll go ahead and close this thread for now. If you have any further questions, please don’t hesitate to open a new thread.

    Thanks!

Viewing 6 posts - 1 through 6 (of 6 total)
  • The topic ‘Exclude Events Tags From Related Events Output’ is closed to new replies.