Skip to content

Instantly share code, notes, and snippets.

Show Gist options
  • Star 2 You must be signed in to star a gist
  • Fork 0 You must be signed in to fork a gist
  • Save cliffordp/a473ccda4308acb9ac66499de5407c9b to your computer and use it in GitHub Desktop.
Save cliffordp/a473ccda4308acb9ac66499de5407c9b to your computer and use it in GitHub Desktop.
TEC | Force list view for search results
<?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 );
@rkantos
Copy link

rkantos commented Aug 21, 2018

Where should this be put in to? Thanks!

@bryanjowens
Copy link

Where should I put this code?

@lindsayweb
Copy link

Is this still working with v2? I added this to functions.php and nothing is happening.

@cliffordp
Copy link
Author

@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