Created
August 26, 2015 12:59
-
-
Save gicolek/832e27a7ac49f238cbc2 to your computer and use it in GitHub Desktop.
Sample shortcode
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 | |
add_shortcode( 'div', 'wp_doin_div_shortcode' ); | |
function wp_doin_div_shortcode($atts, $content = null) { | |
ob_start(); | |
// let's fetch all of the arguments of the shortcode | |
$atts = shortcode_atts( array( | |
'class' => 'wp-doin', | |
'heading' => 'Heading', | |
'subheading' => 'Subheading', | |
), $atts ); | |
// let's output the contents of the shortcode in a custom div | |
?> | |
<div class="<?php echo $atts['class']; ?>"> | |
<h2><?php echo $atts['heading']; ?></h2> | |
<h3><?php echo $atts['subheading']; ?></h3> | |
<?php echo do_shortcode( $content ); ?> | |
</div> | |
<?php | |
return ob_get_clean(); | |
} |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment