I have used the wp-types solution to build a small directory of vendors. All vendors (custom post are under a custom taxonomy). I want to display a list of the taxonomies (vendors categories) and once you click on a vendor category display all vendors under the same classification, but I want to order them by the package their pay for (basic, enhanced and premium).
I got everything working, except for the order of the taxonomy...
Hi roniseS,
Are you going to order the archive page of taxonomies (vendors categories) by custom field "the package their pay for"?
Please try the solution in another thread:
https://toolset.com/forums/topic/sort-custom-post-archive-by-custom-field/
Hello, Thanks for your response,
I am still having trouble, because my custom field is not numerical is a radio field with three options.
Please try add codes in your theme functions.php. like this:
function sort_vendors_archive_loop($query) {
if ($query->is_post_type_archive('vendors') && $query->is_main_query()) {
$query->set('order', 'ASC');
$query->set('meta_key', 'wpcf-pay-for');
$query->set('orderby', 'meta_value');
}
}
add_action('pre_get_posts', 'sort_vendors_archive_loop');
Please replace "vendors" with the custom post type slug of "vendors"
And replace "pay-for" with the slug of custom field "the package their pay for"
More help:
http://codex.wordpress.org/Class_Reference/WP_Query#Order_.26_Orderby_Parameters