Skip to content

Instantly share code, notes, and snippets.

@FernE97
Created March 7, 2012 21:47
Show Gist options
  • Save FernE97/1996448 to your computer and use it in GitHub Desktop.
Save FernE97/1996448 to your computer and use it in GitHub Desktop.
PHP: WordPress Shortcode
<?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