Display Categories and Featured Listings only
-
Hi there. Through the help of the developers of this plugin, I was able to implement a change in how categories and their listings are displayed. What I would like to ultimately do is show Categories and only featured listings in each category. Is this possible? One thing that could help is to know how to specifically target “featured listings” A representation of what we’re trying to do is as follows:
Category Name:
Featured Listing
Don’t display non-featured listingsCategory Name:
Featured Listing
Don’t display non-featured listingsThe code I have is below.
<?php $categories = get_terms( WPBDP_CATEGORY_TAX, 'hide_empty=0' ); ?> <ul> <?php foreach ( $categories as $category ): $listings = get_posts( array( 'post_type' => WPBDP_POST_TYPE, 'tax_query' => array( array( 'taxonomy' => WPBDP_CATEGORY_TAX, 'field' => 'id', 'terms' => $category->term_id ) ) ) ); ?> <li> <!-- Category title & link --> <a>"><?php echo $category->name; ?></a> <!-- Listings under category (only listing title & link) --> <ul class="listings"> <?php foreach ( $listings as $listing ): ?> </li> <li><a>ID ); ?>"><?php echo $listing->post_title; ?></a></li> <?php endforeach; ?> </ul> <?php endforeach; ?>
[Moderator Note: Please post code & markup between backticks or use the code button. Your posted code may now have been permanently damaged by the forum’s parser.]
- The topic ‘Display Categories and Featured Listings only’ is closed to new replies.