Skip to content

Instantly share code, notes, and snippets.

@3200creative
Created September 11, 2017 22:38
Show Gist options
  • Save 3200creative/200154df36411870470176a34cb0d384 to your computer and use it in GitHub Desktop.
Save 3200creative/200154df36411870470176a34cb0d384 to your computer and use it in GitHub Desktop.
Facet Filtering
<?php
$args = array(
'numberposts' => -1,
'post_type' => 'Concerts',
'facetwp' => true,
);
$the_query = new WP_Query( $args );
?>
<?php echo facetwp_display( 'facet', 'state' ); ?>
<section class="facetwp-template">
<?php if( $the_query->have_posts() ): ?>
<?php while ( $the_query->have_posts() ) : $the_query->the_post(); ?>
<li>
<a href="<?php the_permalink(); ?>">
<img src="<?php the_field('event_thumbnail'); ?>" />
<?php the_title(); ?>
</a>
</li>
<?php endwhile; ?>
<?php endif; ?>
</section>
<?php wp_reset_query();?>
<?php
function my_facetwp_is_main_query( $is_main_query, $query ) {
if ( isset( $query->query_vars['facetwp'] ) ) {
$is_main_query = true;
}
return $is_main_query;
}
add_filter( 'facetwp_is_main_query', 'my_facetwp_is_main_query', 10, 2 );
?>
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment