Hyphen/dash in snippet variable stops variable from outputting
-
I have a snippet that creates a shortcode with a variable. It used to work, but stopped working recently.
The variable in the snippet was named video-value. With the hyphen in the variable name, the shortcode does not output the contents of the variable. Renaming the variable to video instead of video-value appears to fix the issue.
However, this does not repair all previous posts in which I have used that snippet, so I’ll need to do a find-and-replace to fix all previous references to video-value.Example (not the actual code generated, but a simplified version):
[youtube video-value="TxB3cee_91E"]
is designed to output
<iframe src="https://www.youtube.com/embed/{video-value}" allowfullscreen allow="" frameborder="0"></iframe>
but it outputs
<iframe src="https://www.youtube.com/embed/" allowfullscreen allow="" frameborder="0"></iframe>Note the missing output after /embed/.
Changing it:
[youtube video="TxB3cee_91E"]
Should output
<iframe src="https://www.youtube.com/embed/{video}" allowfullscreen allow="" frameborder="0"></iframe>
and it works as intended:
<iframe src="https://www.youtube.com/embed/TxB3cee_91E" allowfullscreen allow="" frameborder="0"></iframe>It’s possible this is a bug that showed up in the last update, since I’ve had no problems with the snippet up until recently.
Is there a way to make hyphens work in the variable name again? It would be a lot easier than fixing all previous references to the shortcode.
The topic ‘Hyphen/dash in snippet variable stops variable from outputting’ is closed to new replies.