Skip to content

Instantly share code, notes, and snippets.

@nutsandbolts
Created January 19, 2014 02:31
Show Gist options
  • Star 0 You must be signed in to star a gist
  • Fork 0 You must be signed in to fork a gist
  • Save nutsandbolts/8499664 to your computer and use it in GitHub Desktop.
Save nutsandbolts/8499664 to your computer and use it in GitHub Desktop.
Create a button shortcode to be used in the page/post editor (goes in functions.php)
//* Add shortcode for buttons
function nabm_button_shortcode( $atts, $content = 'Click Here' ) {
extract(shortcode_atts(array(
'url' => '#'
'target' => '',
), $atts));
$target = ($target == 'blank') ? ' target="_blank"' : '';
$button = '<a target=" 'esc_attr( $target ). '" class="button" href="' . esc_url( $url ) . '">' . esc_attr( $content ) . '</a>';
return $button;
}
add_shortcode( 'button', 'nabm_button_shortcode' );
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment