Forked from BeardedGinger/redirec-search-to-list-tec.php
Last active
April 19, 2024 03:49
-
-
Save cliffordp/a473ccda4308acb9ac66499de5407c9b to your computer and use it in GitHub Desktop.
TEC | Force list view for search results
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
<?php | |
// Force list view for search results | |
// updated to the code provided by a forum user at https://theeventscalendar.com/support/forums/topic/forcing-list-view-for-search-results/#post-1259085 | |
// UNTESTED! | |
// from https://gist.github.com/cliffordp/a473ccda4308acb9ac66499de5407c9b | |
add_action( 'wp_footer', function () { | |
// If tribe-events.js hasn't been setup, do nothing | |
if ( ! wp_script_is( 'tribe-events-calendar-script' ) ) { | |
return; | |
} | |
print " | |
<script type='text/javascript'> | |
jQuery( document ).ready( function( $ ) { | |
if ( 'object' !== typeof tribe_ev ) return; | |
var existingSearch = tribe_ev.state.url_params; | |
$( tribe_ev.events ).on( 'tribe_ev_collectParams', function() { | |
var issearch = tribe_ev.state.url_params.match(/tribe\-bar\-search/g); | |
if ( issearch ) { | |
window.location = '/events/?' + tribe_ev.state.url_params + '&eventDisplay=list'; | |
} | |
} ); | |
} ); | |
</script> | |
"; | |
}, 100 ); |
Where should I put this code?
Is this still working with v2? I added this to functions.php and nothing is happening.
@lindsayweb Please contact their support to inquire: https://my.theeventscalendar.com/my-account/support/
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Where should this be put in to? Thanks!