Skip to content

Instantly share code, notes, and snippets.

@lelandf
Created September 15, 2021 21:21
Show Gist options
  • Save lelandf/90b980d2d8ebb086a7cbd05cf91d114f to your computer and use it in GitHub Desktop.
Save lelandf/90b980d2d8ebb086a7cbd05cf91d114f to your computer and use it in GitHub Desktop.
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/';
const miniCalendar = document.querySelector( '.tribe-events-calendar-month' );
// If there's no mini calendar, or if we're already on the redirect-to page
if ( ! miniCalendar || window.location.href === REDIRECTION_URL ) {
return;
}
miniCalendar.addEventListener( 'click', () => {
window.location = REDIRECTION_URL;
});
})();
</script>
<?php });
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment