I know it is possible to filter queries to order posts by the numeric value of a meta. For example, I store the number of total likes for a post in a single meta key :
$query->set('meta_key', 'total_likes' );
$query->set('orderby','meta_value_num');
$query->set('order', 'DESC');
But I would like to filter my query to order posts by the recently viewed items.
To achieve this, I store the time the item was liked in another meta key, which is not single.
Each time a 'time_liked' meta is added, I check the other ones to remove those which are too old.
Does something like this exists; or how can I achieve it ?
$query->set('meta_key', 'time_liked' );
$query->set('orderby', ...); //something like meta_count ?
$query->set('order', 'DESC');