Last active
September 1, 2021 09:28
-
-
Save apsolut/78399ac792e4724173b7145b2ccc691c to your computer and use it in GitHub Desktop.
ACF taxonomy terms to LIST - WordPress Loop
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 | |
| /** | |
| WordPress loop | |
| Taxonomy and Terms | |
| */ | |
| $faq_object = get_sub_field('section_faq_category'); | |
| if( $faq_object ): | |
| foreach ( $faq_object as $faq_object_single ) { | |
| $tax_id_convert = $faq_object_single->term_id; | |
| $tax_id_all[] = $tax_id_convert; | |
| } | |
| $acf_all_tax_list = join(',', $tax_id_all); | |
| $faq_query = new WP_Query( array( | |
| 'post_type' => 'faqs', | |
| 'tax_query' => array( | |
| array( | |
| 'taxonomy' => 'faq_categories', | |
| 'field' => 'term_id', | |
| 'terms' => array( $acf_all_tax_list ) | |
| ) | |
| ), | |
| 'post_status' => 'publish', | |
| 'posts_per_page' => $section_posts | |
| ) ); | |
| ?> | |
| <div class="faq-list flex-list"> | |
| <?php while ( $faq_query->have_posts() ) : $faq_query->the_post(); ?> | |
| <div class="faq-item"> | |
| <div class="heading"> | |
| <div class="card-title font-bold"> | |
| <?php the_title(); ?> | |
| </div> | |
| </div> | |
| <div class="faq-description"> | |
| <?php the_field( 'faq_answer' ); ?> | |
| </div> | |
| </div> | |
| <?php endwhile; ?> | |
| </div> | |
| <?php endif; wp_reset_query(); wp_reset_postdata(); ?> |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment