Hi Marijn,
It is possible to change the order of a view using custom PHP coding.
For that please add a custom PHP code using the method below:
https://toolset.com/documentation/programmer-reference/adding-custom-code/using-toolset-to-add-custom-code/
The code that you need to add should be something like this:
add_filter('wpv_filter_query', function ($query, $setting, $view_id) {
if (in_array($view_id, array(2970))) {
// Set the date when you want the order to start being reversed
$start_date = new DateTime('2023-04-04');
$current_date = new DateTime();
// Calculate the number of days passed since the start date
$days_passed = $start_date->diff($current_date)->days;
// Check if the current week is an even or odd week
$is_even_week = (int)($days_passed / 14) % 2 === 0;
if ($is_even_week) {
$query['orderby'] = array('title' => 'ASC', 'meta_value_num' => 'ASC');
} else {
$query['orderby'] = array('title' => 'DESC', 'meta_value_num' => 'DESC');
}
}
return $query;
}, 999, 3);
In this code snippet, we calculate the number of days that have passed since the specified start date, and then we determine if the current week is an even or odd week. If it's an even week, the order will remain the same, otherwise, the order will be reversed.
Make sure to set the $start_date variable to the date when you want the order to start being reversed. In this example, I used '2023-04-04' as the start date, but you can change it according to your needs.
Also, you need to change 2970 in the code to the ID of the view that you are currently using on your website.
Use this method to find the ID of the view that you use:
https://toolset.com/forums/topic/finding-the-view-id
I did not test the code completely, so you might need to do some tweaks to make it work for your scenario.
Thanks.