Last active
July 14, 2019 20:03
-
-
Save SauntValerian/a79845e301de969017e714a96ffee6da to your computer and use it in GitHub Desktop.
Multiple Loops for FacetWP
This file contains 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