Instantly share code, notes, and snippets.

Embed
What would you like to do?
add_shortcode example
add_shortcode( 'faq', 'process_the_faq_shortcode' );
/**
* Process the FAQ Shortcode to build a list of FAQs.
*
* @since 1.0.0
*
* @param array|string $user_defined_attributes User defined attributes for this shortcode instance
* @param string|null $content Content between the opening and closing shortcode elements
* @param string $shortcode_name Name of the shortcode
*
* @return string
*/
function process_the_faq_shortcode( $user_defined_attributes, $content, $shortcode_name ) {
$attributes = shortcode_atts(
array(
'number_of_faqs' => 10,
'class' => '',
),
$user_defined_attributes,
$shortcode_name
);
// do the processing
// Call the view file, capture it into the output buffer, and then return it.
ob_start();
include( __DIR__ . '/views/faq-shortcode.php' );
return ob_get_clean();
}
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment