Created
September 5, 2017 22:53
-
-
Save DMSpeed/7438bbd27baf6e3d29d455cc491cbcc4 to your computer and use it in GitHub Desktop.
FAQ page built with Advanced Custom Fields (based on WPBeaches)
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 | |
/* | |
Template Name:FAQ Page | |
*/ | |
//Thanks to WPBeaches for this code: https://wpbeaches.com/creating-a-faq-page-in-wordpress-using-acf-and-jquery/ | |
add_action( 'genesis_entry_content', 'wpb_faq_repeater_page', 10 );//Position FAQs after post content | |
function wpb_faq_repeater_page () { | |
//My ACF Fields for reference | |
//faqs - field group | |
//faq_question - sub-field | |
//faq_answer - sub-field | |
// check if the repeater field has rows of data | |
if( have_rows('faq') ): | |
// loop through the rows of data | |
while ( have_rows('faq') ) : the_row(); | |
// display a sub field value | |
echo'<div id="faq_container"> | |
<div class="faq"> | |
<div class="faq_question"> <span class="question">' . get_sub_field('faq_question') . '</span><span class="accordion-button-icon fa fa-plus"></span></div> | |
<div class="faq_answer_container"> | |
<div class="faq_answer"><span>' . get_sub_field('faq_answer') . '</span></div> | |
</div> | |
</div> | |
</div>'; | |
endwhile; | |
else : | |
// no rows found | |
endif; | |
} | |
genesis(); |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment