Created
June 15, 2018 16:27
-
-
Save jrstaatsiii/34e4cb6da73ecbd0fecd6dcadced7f17 to your computer and use it in GitHub Desktop.
FacetWP on COA
This file contains hidden or 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 | |
// Bail if section is set to inactive | |
if ( get_sub_field('status') == 0 ) | |
return; | |
global $tpl_args; | |
$s_classes = array('faqs-template'); | |
$faqs = get_component_field('faqs_to_show'); | |
$category = get_component_field('faq_category'); | |
$posts_per_page = 4; | |
if ( get_component_field('number_of_faqs') ) { | |
$posts_per_page = get_component_field('number_of_faqs'); | |
} | |
$args = array( | |
'post_type' => 'faq', | |
'status' => 'publish', | |
'posts_per_page' => $posts_per_page, | |
'facetwp' => true, | |
); | |
if ( $category ) { | |
$args['tax_query'] = array( | |
array( | |
'taxonomy' => 'faq_category', | |
'field' => 'term_id', | |
'terms' => array($category) | |
) | |
); | |
} | |
$query = new WP_Query( $args ); | |
$style = get_inline_styles(); | |
echo '<section' . section_id_classes( $s_classes ) . $style . '>'; | |
the_section_header( $tpl_args ); | |
if ( $query->have_posts() ) { | |
echo '<div class="grid-container">'; | |
if ( get_component_field('include_search') ) { | |
echo '<div class="grid-x grid-margin-x align-center">'; | |
echo '<div class="cell small-11 medium-12">'; | |
echo '<div class="component search">'; | |
echo facetwp_display('facet', 'faq_search'); | |
echo '</div>'; | |
echo '</div>'; | |
echo '</div>'; | |
} | |
echo '<div class="grid-x grid-margin-x align-center">'; | |
echo '<div class="cell small-11 medium-12">'; | |
echo '<div class="grid-x grid-margin-x small-up-1 medium-up-2 align-center facetwp-template">'; | |
while ( $query->have_posts() ) { | |
$query->the_post(); | |
echo '<div class="cell">'; | |
echo '<div class="faq">'; | |
echo '<h3 class="faq-question">' . get_the_title() . '</h3>'; | |
echo '<div class="faq-answer">'; | |
the_content(); | |
echo '</div>'; | |
echo '</div>'; | |
echo '</div>'; | |
} | |
echo '</div>'; | |
echo '</div>'; | |
echo '</div>'; | |
echo facetwp_display( 'pager' ); | |
wp_reset_postdata(); | |
} | |
echo '</section>'; |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment