Skip to content

Instantly share code, notes, and snippets.

@lelandf
Created September 23, 2021 20:08
Show Gist options
  • Save lelandf/4a9c8e91d586828de20a1c3d8fc51a87 to your computer and use it in GitHub Desktop.
Save lelandf/4a9c8e91d586828de20a1c3d8fc51a87 to your computer and use it in GitHub Desktop.
[TEC] widget events list: change link depending on event category
<?php
/**
* Widget: Events List Event Title
*
* Override this template in your own theme by creating a file at:
* [your-theme]/tribe/events/v2/widgets/widget-events-list/event/title.php
*
* See more documentation about our views templating system.
*
* @link http://evnt.is/1aiy
*
* @version 5.2.1
*
* @var WP_Post $event The event post object with properties added by the `tribe_get_event` function.
*
* @see tribe_get_event() For the format of the event object.
*/
if ( tribe_event_in_category( 'event-category-1', $event->ID ) ) {
$link = 'https://example.com/1/';
} else {
$link = 'https://example.com/2/';
}
?>
<h3 class="tribe-events-widget-events-list__event-title tribe-common-h7">
<a
href="<?php echo esc_url( $link ); ?>"
title="<?php echo esc_attr( $event->title ); ?>"
rel="bookmark"
class="tribe-events-widget-events-list__event-title-link tribe-common-anchor-thin"
>
<?php
// phpcs:ignore
echo $event->title;
?>
</a>
</h3>
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment