Created
January 4, 2017 03:22
-
-
Save hellofromtonya/ced966dd791820c50aa8010dd582d222 to your computer and use it in GitHub Desktop.
add_shortcode example
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
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