I've an elementor pro page hidden link which is trying to sort walking tours by date.
The underlying date is from a custom post called Walking Tours (walking-tours) at hidden link
and has a Field Group for Walking Tours at hidden link
which includes a repeating field called Date/Time of Tour (datetime-of-tour).
The walks-grid page shows the date of tours taken from Date/Time of Tour, but I'm trying to work out how to sort this so that the earliest tours appear first (and only from todays date). I've explored various plugins for sorting by custom fields (Advanced Post Queries and Advanced Query Loop), but they don't seem to support Toolset.
My next attempt was to try and use a PHP code snippet (copying from others attempts as I don't really understand PHP):
<?php
add_action( 'elementor/query/walks_post_sort', function( $query ) {
$query->set('post_type', 'walking-tour');
$query->set( 'meta_key', 'datetime-of-tour' );
$query->set( 'orderby', 'meta_value_num' );
$query->set( 'order', 'DESC' );
});
If I activate this snippet then the query fails and the walks-grid page is blank.
I think it is probably failing because datetime-of-tour is a repeating field. Is there a way to sort by the first field in the array of repeating dates?
Is there any documentation that you are following?
Hello. Thank you for contacting the Toolset support.
You shared the backend links but I could not access those links until I login to backend addmin.
Can you please send me wp-admin access details and once I review your current setup I will be able to guide you in the right direction.
*** Please make a FULL BACKUP of your database and website.***
I would also eventually need to request temporary access (WP-Admin and FTP) to your site. Preferably to a test site where the problem has been replicated if possible in order to be of better help and check if some configurations might need to be changed.
I have set the next reply to private which means only you and I have access to it.
- The change is - Types stores the custom field slug with "wpcf-" prefix. So if you have custom field "name" then the meta key for that will be stored as "wpcf-name".