Related Events Only Specific Category

Home Forums Calendar Products Events Calendar PRO Related Events Only Specific Category

  • This topic has 3 replies, 2 voices, and was last updated 9 years ago by Meghan Fuller.
Viewing 3 posts - 1 through 3 (of 3 total)
  • Author
    Posts
  • #1268249
    Meghan Fuller
    Participant

    Is there a way to set the related events to only display events from a specific category?

    Thanks so much for your help!

    #1269738
    Barry
    Member

    Hi Meghan,

    That’s certainly possible though it requires adding some custom code – either to your theme’s functions.php file or (preferably) a custom plugin. The basic form looks something like this:

    function events_related_posts_override( array $query_args ) {
    	$query_args[ 'tax_query' ] = array(
    		array(
    			'taxonomy' => Tribe__Events__Main::TAXONOMY,
    			'field'    => 'slug',
    			'terms'    => 'birthdays',
    		)
    	);
    
    	return $query_args;
    }
    
    add_filter( 'tribe_related_posts_args', 'events_related_posts_override' );

    In the above example, I’m limiting related posts to those assigned to a category with a slug of ‘birthdays’, but you could easily adjust as needed.

    Does that help at all?

    #1279317
    Support Droid
    Keymaster

    Hey there! This thread has been pretty quiet for the last three weeks, so we’re going to go ahead and close it to avoid confusion with other topics. If you’re still looking for help with this, please do open a new thread, reference this one and we’d be more than happy to continue the conversation over there.

    Thanks so much!
    The Events Calendar Support Team

Viewing 3 posts - 1 through 3 (of 3 total)
  • The topic ‘Related Events Only Specific Category’ is closed to new replies.