Order posts by custom date field
-
I would like the serach results to be ordered by a custom date field (auction_date_new). I use this same field to order the posts on archive pages. BUt it’s not working for the search page.
I have tried the filter:
add_filter( 'relevanssi_modify_wp_query', 'rlv_desc_date' ); function rlv_desc_date( $query ) { $query->set( 'meta_key', 'auction_date_new' ); $query->set( 'order', 'DESC' ); $query->set( 'orderby', 'meta_value_date' ); return $query; }
and variations of it. It changes the order, but seemingly randomly. It’s not in order of date (newest to oldest).
Viewing 4 replies - 1 through 4 (of 4 total)
Viewing 4 replies - 1 through 4 (of 4 total)
- The topic ‘Order posts by custom date field’ is closed to new replies.