Skip to content

Instantly share code, notes, and snippets.

View lelandf's full-sized avatar

Leland Fiegel lelandf

View GitHub Profile
@lelandf
lelandf / title.php
Created September 23, 2021 20:08
[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
@lelandf
lelandf / title.php
Created September 22, 2021 22:45
[TEC] override single event title template part to include start date
<?php
/**
* Single Event Title Template Part
*
* Override this template in your own theme by creating a file at:
* [your-theme]/tribe/events/single-event/title.php
*
* See more documentation about our Blocks Editor templating system.
*
* @link http://evnt.is/1aiy
@lelandf
lelandf / snippet.php
Created September 21, 2021 16:09
[TEC] Set doctitle to include event category name.
<?php
add_filter( 'pre_get_document_title', function( $title ){
if ( is_tax( 'tribe_events_cat' ) ) {
$queried_object = get_queried_object();
// Set title to: [Tribe Events Category Name] - [WordPress Site Title]
$title = $queried_object->name . ' - ' . get_bloginfo( 'name' );
}
@lelandf
lelandf / snippet.php
Created September 20, 2021 13:55
[TEC] filter tribe_get_venue_link example
<?php
add_filter( 'tribe_get_venue_link', function( $link, $venue_id ) {
$just_the_title = get_the_title( $venue_id );
return $just_the_title;
}, 10, 2 );
@lelandf
lelandf / multiday-event.php
Created September 17, 2021 22:01
[TEC] template override for multiday events appearing not multiday
<?php
<?php
/**
* View: Month View - Multiday Event
*
* Override this template in your own theme by creating a file at:
* [your-theme]/tribe/events/v2/month/calendar-body/day/multiday-events/multiday-event.php
*
* See more documentation about our views templating system.
*
@lelandf
lelandf / snippet.php
Created September 17, 2021 22:00
[TEC] Tame the multiday classes if you don't want them to actually appear like that
<?php
add_filter( 'tribe_events_views_v2_month_multiday_classes', function( $classes ) {
// Get rid of "width" class
$needle = "tribe-events-calendar-month__multiday-event--width-";
foreach ( $classes as $i => $haystack ) {
if ( 0 === strpos( $haystack, $needle ) ) {
unset( $classes[$i] );
}
}
@lelandf
lelandf / snippet.php
Last active September 17, 2021 20:41
[TEC] tribe_get_venue filter example, override link
<?php
add_filter( 'tribe_get_venue', function( $venue, $venue_id ) {
$venue = get_the_title( $venue_id );
return $venue;
}, 11, 2 );
@lelandf
lelandf / dropdown.php
Last active October 5, 2023 23:05
[TEC] Template override to get rid of unwanted filter bar categories
<?php
/**
* View: Dropdown Component
*
* Override this template in your own theme by creating a file at:
* [your-theme]/tribe/events-filterbar/v2_1/components/dropdown.php
*
* See more documentation about our views templating system.
*
* @link http://evnt.is/1aiy
@lelandf
lelandf / snippet.php
Created September 15, 2021 21:21
Redirect to arbitrary URL after clicking Mini Calendar Widget
<?php
// Use at your own risk!
// No warranty, no support provided
add_action( 'wp_footer', function() { ?>
<script>
(function () {
// Change your redirection URL here
const REDIRECTION_URL = 'https://www.example.com/events/';
@lelandf
lelandf / snippet.php
Created September 15, 2021 19:43
Venue archives in The Events Calendar
<?php
// Adjust args
add_filter( 'register_post_type_args', function( $args, $post_type ) {
if ( 'tribe_venue' === $post_type ) {
$args['has_archive'] = true;
}
return $args;
}, 10, 2 );