FAQ Section
This is a Frequently Asked Question
This is the answer
Shortcode Text
Note: Trim double brackets to single brackets.
[faq_section_start]
[faq_question]] This is a Frequently Asked Question [[/faq_question]
[faq_answer]] This is the answer [[/faq_answer]
[faq_section_end]
Code (Add to Functions.php)
function faq_section_start_function($atts){
$code_return = ‘<div itemscope=”” itemType=”https://schema.org/FAQPage”>’;
return $code_return;
}
add_shortcode( ‘faq_section_start’, ‘faq_section_start_function’ );
function faq_question_function($atts, $content = null){
$code_return = ‘<div itemscope=”” itemProp=”mainEntity” itemType=”https://schema.org/Question”><div itemProp=”name”><h3>’.$content.'</h3></div>’;
return $code_return;
}
add_shortcode( ‘faq_question’, ‘faq_question_function’ );
function faq_answer_function($atts, $content = null){
$code_return = ‘<div itemscope=”” itemProp=”acceptedAnswer” itemType=”https://schema.org/Answer”><div itemProp=”text”><p>’.$content.'</p></div></div>’;
return $code_return;
}
add_shortcode(‘faq_answer’,’faq_answer_function’);
function faq_section_end_function($atts){
$code_return = ‘</div>’;
return $code_return;
}
add_shortcode(‘faq_section_end’,’faq_section_end_function’);