Skip to content

Instantly share code, notes, and snippets.

Show Gist options
  • Star 0 You must be signed in to star a gist
  • Fork 0 You must be signed in to fork a gist
  • Save ouadie-limouni/26cbbaa767ab4086c8fb9cfbf07d7299 to your computer and use it in GitHub Desktop.
Save ouadie-limouni/26cbbaa767ab4086c8fb9cfbf07d7299 to your computer and use it in GitHub Desktop.
Sample page
<?php
get_header();
?>
<div id="filtersidebar" class="col-md-3" style="border: 1px solid lightgray;">
<?php echo do_shortcode('[facetwp facet="filter_by_flavor_acf"]'); ?>
<?php echo do_shortcode('[facetwp facet="filter_by_product_type_acf"]'); ?>
<?php echo do_shortcode('[facetwp facet="filter_by_packaging_type_acf"]'); ?>
</div>
<?php
/** Get all terms from the 'seasons' Taxonomy and order the array by the value of "description" */
$terms = get_terms('seasons', 'orderby=description&hide_empty=1');
/** Loop through each term one by one and output the posts that are assoiated to it */
if(!empty($terms)) : foreach($terms as $term) :
/** Set the term name */
$term_name = $term->slug;
/** Set the query arguments and run the query*/
$args = array(
'seasons' => $term_name,
'orderby' => 'title',
'order' => DESC,
'post_type' => 'candy',
'posts_per_page' => -1,
'facetwp' => true
);
$term_posts = new WP_Query($args);
/** Do something with all of the posts */
if($term_posts->have_posts()) : while ($term_posts->have_posts()) : $term_posts->the_post();
the_title();
endwhile;
endif;
/** Reset the postdata, just because it's neat and tidy to do so, even if you don't need it again */
wp_reset_postdata();
endforeach;
endif;
?>
<?php echo do_shortcode('[facetwp pager="true"]'); ?>
<?php get_footer(); ?>
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment