Skip to content

Instantly share code, notes, and snippets.

@SauntValerian
Last active July 14, 2019 20:03
Show Gist options
  • Star 0 You must be signed in to star a gist
  • Fork 2 You must be signed in to fork a gist
  • Save SauntValerian/a79845e301de969017e714a96ffee6da to your computer and use it in GitHub Desktop.
Save SauntValerian/a79845e301de969017e714a96ffee6da to your computer and use it in GitHub Desktop.
Multiple Loops for FacetWP
<?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