-1

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; ?>

1 Answer 1

0

I think that if you make your choices list a value=>label list, this should work: https://wordpress.stackexchange.com/a/11454/20807

Instead of your current list,

1 : Ultimate Plus
2 : Ultimate
3 : Professional
4 : Commercial
5 : Business
6 : Free

It can also be in the order that you currently have

6 : Free
5 : Business
4 : Commercial
3 : Professional
2 : Ultimate
1 : Ultimate Plus

Then, the meta_key / orderby combo should get you where you want.

More info about ACF's Select field type: http://www.advancedcustomfields.com/resources/select/

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service and acknowledge you have read our privacy policy.

Not the answer you're looking for? Browse other questions tagged or ask your own question.