Support » Developing with WordPress » inline scripts get removed from page-template

  • Hi everyone,

    i have to implement an inline-script which creates an iframe with additional content on a specific page.

    I’ve already tried different approaches:
    – I’ve created a Shortcode in the functions.php
    – I set up an individual page template which is used on the specific page and added the script
    – I even tried various script implementation plugins

    They all seem to work as long as im logged in, but when i visit the page without being logged in the inline scripts seems to get removed from the output.

    The Script looks like this:

    <script src=”https:/xxx.js” data-xxx-microsite data-shop-id=”xx” data-lang=”xxx” data-domain=”; async></script>

    I’m running out of ideas. Anyone got a clue?

    Thank you

Viewing 1 replies (of 1 total)
  • Moderator bcworkz


    HTML script tags on a page template shouldn’t be stripped if one is not logged in, unless the tag was placed within a PHP conditional that checks logged in status. Tags like that really belong in the page’s head section, so a shortcode or page template isn’t the best choice, assuming your theme outputs head section content from a different template, common to all pages. Usually header.php.

    You presumably don’t want this tag on all pages, so I recommend hooking the “wp_print_scripts” action and conditionally outputting the tag when get_queried_object_id() returns the ID of the page where you want the tag to appear. Action hook code can reside in functions.php of your theme, or in a custom plugin you’ve created for all of your custom code.

Viewing 1 replies (of 1 total)
  • You must be logged in to reply to this topic.