Skip to content

Instantly share code, notes, and snippets.

@tcmulder
Created October 9, 2023 13:42
Show Gist options
  • Save tcmulder/e4c4f92ce057c7c2206cce7307c3b0f3 to your computer and use it in GitHub Desktop.
Save tcmulder/e4c4f92ce057c7c2206cce7307c3b0f3 to your computer and use it in GitHub Desktop.
WordPress Shortcode Starter
<?php
/**
* Add shortcode
*/
add_shortcode( 'button', 'aqua_btn_shortcode' );
function aqua_btn_shortcode( $attr, $content = "" ) {
extract( shortcode_atts( array(
'label' => 'Button',
'link' => '#',
'new_tab' => '',
'class' => ''
), $attr ) );
$html = sprintf(
'<a href="%s"%s%s>%s</a>',
$link,
$new_tab ? ' target="_blank"' : '',
$class ? ' class="' . $class . '"' : '',
$label
);
return $html;
}
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment