Skip to content

Instantly share code, notes, and snippets.

@kovshenin
Created July 19, 2012 14:05
Show Gist options
  • Star 2 You must be signed in to star a gist
  • Fork 0 You must be signed in to fork a gist
  • Save kovshenin/3144162 to your computer and use it in GitHub Desktop.
Save kovshenin/3144162 to your computer and use it in GitHub Desktop.
Here's why you should not use dashes in WordPress shortcodes
<?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
*/
@kovshenin
Copy link
Author

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment