Support » Fixing WordPress » <script> tag removed from Custom HTML block

  • Resolved manur76


    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 -->
    <!-- /wp:paragraph -->
    <!-- wp:html -->
    <script>document.write('<div>hello world</div>');</script>
    <!-- /wp:html -->
    <!-- wp:paragraph -->
    <!-- /wp:paragraph -->

    But when I publish, this is always what gets outputted :

    	<div class="entry-content">
    document.write(&lsquo;<div>hello world</div>&lsquo;);
    			</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” (

    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 :

    Thanks in advance for your help.

Viewing 2 replies - 1 through 2 (of 2 total)
  • I’m not sure it changed for the new editor, but the Classic Editor strips tags if the user does not have unfiltered_html capability.

    Thanks a lot @joyously !
    My login user for this site was not super-admin (only admin) and thus (because it’s a multisite install) did not have that capability.
    Making this user super-admin made it work.

    Cheers !

Viewing 2 replies - 1 through 2 (of 2 total)
  • The topic ‘<script> tag removed from Custom HTML block’ is closed to new replies.