Created
July 14, 2019 20:03
-
-
Save pije76/9a98eb0f0c209cee7988dd707e29de5b to your computer and use it in GitHub Desktop.
Multiple Loops for FacetWP
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
<?php $args = array( | |
'post_type' => 'location', | |
'posts_per_page' => -1, | |
'order' => 'ASC', | |
'orderby' => 'title', | |
'facetwp' => true, | |
'tax_query' => array( | |
array( | |
'taxonomy' => 'advertiser-level', | |
'field' => 'slug', | |
'terms' => array( | |
'platinum', | |
'gold', | |
'silver', | |
'bronze' | |
), | |
), | |
) | |
); | |
$query = new WP_Query($args); ?> | |
<div class="entries"> | |
<?php if ($query->have_posts()) { | |
while ($query->have_posts()) { $query->the_post(); | |
if (has_term('platinum','advertiser-level')) { ?> | |
<div class="facetwp-template"> | |
<div class="location_indv_post platinum"> | |
//// Do some templating stuff unique to this level | |
</div> | |
</div> | |
<?php } } } ?> | |
<?php $query->rewind_posts(); ?> | |
<?php if ($query->have_posts()) { | |
while ($query->have_posts()) { $query->the_post(); | |
if (has_term('gold','advertiser-level')) { ?> | |
<div class="facetwp-template"> | |
<div class="location_indv_post gold"> | |
/// Do some templating stuff unique to this level | |
</div> | |
</div> | |
<?php } } } ?> | |
<?php $query->rewind_posts(); ?> | |
<?php if ($query->have_posts()) { | |
while ($query->have_posts()) { $query->the_post(); | |
if (has_term('silver','advertiser-level')) { ?> | |
<div class="facetwp-template"> | |
<div class="location_indv_post silver"> | |
/// Do some templating stuff unique to this level | |
</div> | |
</div> | |
<?php } } } ?> | |
<?php $query->rewind_posts();?> | |
<?php if ($query->have_posts()) { | |
while ($query->have_posts()) { $query->the_post(); | |
if (has_term('bronze','advertiser-level')) { ?> | |
<div class="facetwp-template"> | |
<div class="location_indv_post bronze"> | |
/// Do some templating stuff unique to this level | |
</div> | |
</div> | |
<?php } } } ?> | |
<?php wp_reset_postdata(); ?> | |
</div><!-- .entries --> |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment