Navigation

    Digital Liberation Forums

    • Register
    • Login
    • Search

    footer script disable on a single page

    Header and Footer Scripts
    2
    4
    34
    Loading More Posts
    • Oldest to Newest
    • Newest to Oldest
    • Most Votes
    Reply
    • Reply as topic
    Log in to reply
    This topic has been deleted. Only users with topic management privileges can see it.
    • Jeroen Claessens
      Jeroen Claessens last edited by

      Hello.

      I have received a working script from my helpdesk software, but I don't want this script to run on one specific page in Wordpress.

      This page has ID 920.

      How can I get the script below to run normally, except on the page with ID 920?

      I would love to hear from you.

      <script type="text/javascript">
      window.Trengo = window.Trengo || {};
      window.Trengo.key = 'xxxxxxxxxxxxxxxxxxx';
      (function(d, script, t) {
      script = d.createElement('script');
      script.type = 'text/javascript';
      script.async = true;
      script.src = 'https://xxxx.xxxxxx.xxxxxx/embed.js';
      d.getElementsByTagName('head')[0].appendChild(script);
      }(document));

      window.addEventListener('keydown', function(e) {
      if(e.keyCode == 32 && e.target == document.body) {
      e.preventDefault();
      }
      });
      </script>

      1 Reply Last reply Reply Quote
      • anand
        anand last edited by

        Hello,

        Unfortunately there is not an easy way to do that with the plugin. But you may use your theme's functions.php file to insert the code using simple if else statement.

        HTH

        1 Reply Last reply Reply Quote
        • Jeroen Claessens
          Jeroen Claessens last edited by

          Can you help me with that if/else statement?

          1 Reply Last reply Reply Quote
          • anand
            anand last edited by

            It could be something like this:

            function anand657_hook_javascript() {
              if (!is_page ('920')) { 
                ?>
                    <script type="text/javascript">
                      // your javscript code goes here
                    </script>
                <?php
              }
            }
            add_action('wp_footer', 'anand657_hook_javascript');
            

            PS: DON'T RUN THE ABOVE CODE ON LIVE SITE UNLESS YOU HAVE A BACKUP. it might break your site if any thing goes wrong. It's good to have backup handy.

            1 Reply Last reply Reply Quote
            • First post
              Last post