Shortcodes remove some html
-
Hello all,
I’m having trouble outputting some html from a WordPress shortcode. It removes some of the code but not everything.
function sound_intro($atts) { ob_start(); ?> <select on="change:AMP.setState({ activeDiv: event.value })"> <option value=0></option> <option value=1>Div 1</option> <option value=2>Div 2</option> </select> <div hidden [hidden]="activeDiv != 1">Div 1</div> <div hidden [hidden]="activeDiv != 2">Div 2</div> <?PHP $contents = ob_get_contents(); file_put_contents("<somewhere>",$contents,FILE_APPEND); ob_end_clean(); return $contents; } add_shortcode( 'sound_intro', 'sound_intro' );This code results in the following code in my browser:
<select on="change:AMP.setState({ activeDiv: event.value })"> <option value="0"></option> <option value="1">Div 1</option> <option value="2">Div 2</option> </select> </p> <div hidden>Div 1</div> <div hidden>Div 2</div>So as you can see some html is missing and it breaks the logic of what I want to achieve.
I’m storing the html in a text file before outputting the results and in this file, the html is perfectly preserved. This would mean that between the “return” and the actual display, WordPress is stripping some code away.
do you have any idea of what is happening?
Thanks
Viewing 3 replies - 1 through 3 (of 3 total)
Viewing 3 replies - 1 through 3 (of 3 total)
The topic ‘Shortcodes remove some html’ is closed to new replies.