Sort by multiple options in custom field

Question

With use of the Advanced Custom Fields plugin I created a select dropdown which contains 6 membership types. All of my ‘listings’ using this custom field are assigned one of the 6.

enter image description here

I’d like to display all ‘listings’ by:

Ultimate Plus
Ultimate
Professional
Commercial
Business
Free

In this particular order, so those paying for the highest level membership have their ‘listing’ appear at the top of the page.

I expected it to be similar to this which I just found but unsure exactly:

// args
$args = array(
'post_type'  => 'directory_listings',
'meta_key'   => 'free',
'orderby'    => 'meta_value_num',
'order'      => 'ASC',
'meta_query' => array(
    array(
        'key'     => '#',
        'value'   => array( #, # ),
        'compare' => 'IN',
    ),
),
);

// query
$wp_query = new WP_Query( $args );

?>

<?php if (have_posts()) : ?>

    <?php
    while( $wp_query->have_posts() ) {
        the_post();
        ldl_get_template_part('listing', 'compact');
        ldl_get_featured_posts();
    }
    ?>

<?php else : ?>

<?php endif; ?>
0
, wharfdale 9 years 2014-11-20T07:22:45-05:00 0 Answers 67 views 0

Leave an answer

Browse
Browse