<script> tag removed from Custom HTML block
-
On a WordPress Page, I can’t get to output a <script> tag to the resulting HTML. It is stripped.
I used WordPress 5.1.1 and upgraded to 5.2, with the new editor.
I have a multisite install.On a new Page I created three blocks :
<!-- wp:paragraph --> <p>before</p> <!-- /wp:paragraph --> <!-- wp:html --> <script>document.write('<div>hello world</div>');</script> <!-- /wp:html --> <!-- wp:paragraph --> <p>after</p> <!-- /wp:paragraph -->
But when I publish, this is always what gets outputted :
<div class="entry-content"> <p>before</p> document.write(‘<div>hello world</div>‘); <p>after</p> </div><!-- .entry-content -->
When I open the Page afterwards to edit it, the <script> tags have been stripped in the page content itself.
The documentation for the Custom HTML block says that it should be used to “include custom <script> tags” (https://gogutenberg.com/blocks/custom-html/).
Things I have tried, which failed :
– Upgrading to 5.2
– Deactivating all plug-ins
– Installing and using the Classic Editor plug-in to type the Page content
– Adding this to functions.php : https://www.denisbouquet.com/stop-wordpress-removing-tags-without-plugins/Thanks in advance for your help.
- The topic ‘<script> tag removed from Custom HTML block’ is closed to new replies.