Skip to content

Instantly share code, notes, and snippets.

@intelliweb
Last active January 3, 2018 15:10
Show Gist options
  • Save intelliweb/5383647 to your computer and use it in GitHub Desktop.
Save intelliweb/5383647 to your computer and use it in GitHub Desktop.
WP: add shortcode. Replace SHORTCODE_TAG with whatever text you want to use in the shortcode.
<?php
// Shortcode: [SHORTCODE_TAG]
add_shortcode('SHORTCODE_TAG', 'intw_shortcode_SHORTCODE_TAG');
function intw_shortcode_SHORTCODE_TAG($atts) {
extract( shortcode_atts( array(
'att1' => 'DEFAULT_VALUE',
'att2' => 'DEFAULT_VALUE',
), $atts ) );
ob_start(); ?>
<!-- START SHORTCODE OUTPUT -->
<div class="">
<a href="<?php echo $att1; ?>"><?php echo $att2; ?></a>
</div>
<!-- END SHORTCODE OUTPUT -->
<?php return ob_get_clean();
}
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment