Opened 12 years ago
Closed 12 years ago
#21257 closed defect (bug) (duplicate)
Shortcode not working when another earlier defined shortcode contains new shortcode
Reported by: | dannydehaan | Owned by: | |
---|---|---|---|
Milestone: | Priority: | normal | |
Severity: | normal | Version: | |
Component: | Shortcodes | Keywords: | |
Focuses: | Cc: |
Description
Hi All,
Hope my summary is clear enough.
The problem.
When you want to register a new shortcode and another shortcode that contains the new shortcode string is registered earlier, the earlier shortcode will be used by WordPress.
To make it more clear, here's an example.
add_shortcode( 'this-is-a-shortcode', 'this_is_a_shortcode' ); add_shortcode( 'this-is-a-shortcode-1', 'this_is_a_shortcode_1' ); function this_is_a_shortcode() { return 'Shortcode Used'; } function this_is_a_shortcode_1() { return 'Shortcode 1 Used'; }
When i use the above and i call [this-is-a-shortcode-1] in my content, i get Shortcode Used instead of Shortcode 1 Used.
When you change the order of the shortcode registration, WordPress will return Shortcode 1 Used like it should be.
add_shortcode( 'this-is-a-shortcode-1', 'this_is_a_shortcode_1' ); add_shortcode( 'this-is-a-shortcode', 'this_is_a_shortcode' ); function this_is_a_shortcode() { return 'Shortcode Used'; } function this_is_a_shortcode_1() { return 'Shortcode 1 Used'; }
I already searched in the wp-includes/shortcodes.php, but i saw a regex there and thougt... This isn't a fix for me ;)
Change History (2)
Note: See
TracTickets for help on using
tickets.
See http://codex.wordpress.org/Shortcode_API#Hyphens