Reputation: 752
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.
I have managed to get my listings to display in order of membership level, however it's not defining by category that your currently in. It's grabbing listings from every other category too.
<?php
// args
$args = array(
'numberposts' => -1,
'post_type' => 'directory_listings',
'meta_key' => 'membership_type',
'orderby' => 'meta_value',
'taxonomy' => 'listing_category'
);
// 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; ?>
Also, I am using the plugin: https://wordpress.org/plugins/ldd-directory-lite/
Upvotes: 0
Views: 478
Reputation: 6828
WP_Query does not have a taxonomy
parameter, you should use tax_query
instead. More info in the Codex.
'tax_query' => array(
array(
'taxonomy' => 'listing_category',
'field' => 'slug',
'terms' => 'my-listing-category',
),
),
To grab the current taxonomy term dynamically (assuming you're on a listing_category
taxonomy page):
'tax_query' => array(
array(
'taxonomy' => 'listing_category',
'field' => 'term_id',
'terms' => get_queried_object_id(),
),
),
Upvotes: 1