Created
September 11, 2017 22:38
-
-
Save 3200creative/200154df36411870470176a34cb0d384 to your computer and use it in GitHub Desktop.
Facet Filtering
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 | |
$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();?> |
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 | |
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