AnsPress_Question_Shortcode::anspress_question_sc( array $atts, string $content = '' )
Description #
Control the output of [question] shortcode
Parameters #
- $attsarray (Required) Attributes.
- $contentstring (Optional) Content. Default value: ''
Source #
File: includes/shortcode-question.php
public function anspress_question_sc( $atts, $content = '' ) { // phpcs:ignore Generic.CodeAnalysis.UnusedFunctionParameter.FoundAfterLastUsed
ob_start();
echo '<div id="anspress" class="ap-eq">';
/**
* Action is fired before loading AnsPress body.
*/
do_action( 'ap_before_question_shortcode' );
$id = ! empty( $atts['ID'] ) ? absint( $atts['ID'] ) : absint( $atts['id'] );
$questions = ap_get_question( $id );
if ( $questions->have_posts() ) {
/**
* Set current question as global post
*
* @since 2.3.3
*/
while ( $questions->have_posts() ) :
$questions->the_post();
include ap_get_theme_location( 'shortcode/question.php' );
endwhile;
} else {
esc_attr_e( 'Invalid or non existing question id.', 'anspress-question-answer' );
}
echo '</div>';
wp_reset_postdata();
return ob_get_clean();
}
Expand full source code Collapse full source code View on GitHub: includes/shortcode-question.php:47
Add your comment