public
Created

Here's why you should not use dashes in WordPress shortcodes

  • Download Gist
shortcodes-test.php
PHP
1 2 3 4 5 6 7 8 9 10 11 12 13
<?php
// Shortcodes
add_shortcode( 'my', function() { return 'my'; } );
add_shortcode( 'my-shortcode', function() { return 'my-shortcode'; } );
add_shortcode( 'my_shortcode', function() { return 'my_shortcode'; } );
 
/**
* Results:
*
* [my] - my
* [my-shortcode] - my (didn't expect it, did you?)
* [my_shortcode] - my_shortcode
*/

Please sign in to comment on this gist.

Something went wrong with that request. Please try again.