Created
March 7, 2012 21:47
-
-
Save FernE97/1996448 to your computer and use it in GitHub Desktop.
PHP: WordPress 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( 'basic_shortcode', 'basic_shortcode' ); | |
function basic_shortcode($atts) { | |
$atts = shortcode_atts( | |
array( | |
'title' => 'My Shortcode' | |
), $atts); | |
ob_start(); | |
?> | |
<h3><?php echo $atts['title']; ?></h3> | |
<?php | |
$content = ob_get_clean(); | |
return $content; | |
} | |
// [basic_shortcode title="New Title"] |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment