Created
July 16, 2018 14:03
-
-
Save olim-dev/26cbbaa767ab4086c8fb9cfbf07d7299 to your computer and use it in GitHub Desktop.
Sample page
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 | |
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