Ordering of Results
-
Hello,
I would like to order the filter results by a custom field. Please could you let me know if I could do that like this:
add_action( 'pre_get_posts', 'sort_rentals' ); function sort_rentals( $query ) { if if(!is_admin() && is_post_type_archive('rental')) { $query->set('meta_key', 'ranking' ); $query->set('orderby', ''meta_value_num'); } return $query; }
If so, would I need to specify an archive type for each taxonomy?
Thank you for your help ??
Viewing 2 replies - 1 through 2 (of 2 total)
Viewing 2 replies - 1 through 2 (of 2 total)
- The topic ‘Ordering of Results’ is closed to new replies.