Sort events in a list
-
Hi,
I would like to ask for help. I don’t know much about it.
I have The Event Calendar plugin on the page and here are the tournaments that I need to sort from newest to oldest. At the same time to select the date from which the list will be displayed.
In short, for example: I need to show all tournaments from 1.1.2021 in order from newest to oldest
I have tried some php scripts, but always without success. Only all tournaments from a certain date have been viewed using php in functions.php:
/* * Set the default date for views like List and Month * Modify the $date variable below to set your date*/ function tribe_set_default_date( $wp_query ) { // Only run on main event queries if ( ! tribe_is_event_query() || ! $wp_query->is_main_query() || $wp_query->get( 'eventDate' ) != '') return; // Set this to the date you want shown, in YYYY-MM-DD format $date = '2020-05-01'; // Select which TEC views you want this to apply to by uncommenting them if ( tribe_is_list_view() // || tribe_is_map() // || tribe_is_photo() // || tribe_is_month() // || tribe_is_week() // || tribe_is_day() ) { $wp_query->set( 'eventDate', $date ); } } if ( function_exists('tribe_is_event_query') ) { add_action( 'parse_query', 'tribe_set_default_date', 100); } /* * Sets the date search value to never be blank*/ function tribe_bar_set_date_val( $filters ) { global $wp_query; $new_val = 'value="' . esc_attr( $wp_query->get( 'eventDate' ) ) . '"'; $filters['tribe-bar-date']['html'] = preg_replace( '/value="[^"]*"/', $new_val, $filters['tribe-bar-date']['html'] ); return $filters; } add_filter( 'tribe-events-bar-filters', 'tribe_bar_set_date_val', 100, 1 );
Thank you very much for any help
MíraThe page I need help with: [log in to see the link]
Viewing 2 replies - 1 through 2 (of 2 total)
Viewing 2 replies - 1 through 2 (of 2 total)
- The topic ‘Sort events in a list’ is closed to new replies.