Multiple Loops for FacetWP

mgibbs189

{{gist file=”custom-loop.php” lang=”php”}}
<?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’
),
),
)
);

$posts = array();

// Loop through the posts, storing data into the $posts array
$query = new WP_Query( $args );
if ( $query->have_posts() ) {
while ( $query->have_posts() ) {
$query->the_post();
$terms = wp_get_object_terms( $post->ID, ‘advertiser-level’, array( ‘fields’ => ‘slugs’ ) );
$posts[ $terms[0] ][] = $post;
}
}

?>

<div class=”entries”>
<div class=”facetwp-template”>
<?php foreach ( $posts as $tier => $post_arrays ) : ?>
<div class=”location_indv_post <?php echo $tier; ?>”>
<?php foreach ( $post_arrays as $post_obj ) : ?>
<?php setup_postdata( $post_obj ); ?>

<!– PLATINUM –>

<?php if ( ‘platinum’ == $tier ) : ?>
Paste this code: https://gist.github.com/SauntValerian/60566a02f9f4dc5fba79af38096d4f65#file-tier-sections-php-L4-L63
<?php endif; ?>

<!– GOLD –>

<?php if ( ‘gold’ == $tier ) : ?>
Paste this code: https://gist.github.com/SauntValerian/60566a02f9f4dc5fba79af38096d4f65#file-tier-sections-php-L67-L105
<?php endif; ?>

<!– SILVER –>

<?php if ( ‘platinum’ == $tier ) : ?>
Paste this code: https://gist.github.com/SauntValerian/60566a02f9f4dc5fba79af38096d4f65#file-tier-sections-php-L109-L130
<?php endif; ?>

<?php endforeach; ?>
</div>
<?php endforeach; ?>
</div>
</div><!– .entries –>
{{/gist}}