• Resolved wrip

    (@wrip)


    I am using a jquery script in the wysiwyg editor of a page like this:

    <script type="text/javascript">// <![CDATA[
    jQuery(document).ready(function () {
      .....
      .....
      if (abc == 69 && xyz == 20) var isHere = true;
      ....
      ....
    });
    // ]]></script>

    However, it seems like && is translated to & #038;& #038; when the page loads. How do I prevent this from happening? I have tried &amp ; but that does not work.

Viewing 6 replies - 1 through 6 (of 6 total)
  • Moderator Samuel Wood (Otto)

    (@otto42)

    WordPress.org Admin

    Did you try to put it in in the “Text” tab instead of using the “Visual” tab?

    Thread Starter wrip

    (@wrip)

    Yes I did put it in the “Text” tab.

    Try putting the js somewhere other than the content for one. The filters that are applied to the content are frequently modified by plugins and themes making it nearly impossible to predict exactly what will be output in your specific setup.

    Perhaps put the js into the theme footer?

    Thread Starter wrip

    (@wrip)

    Yes I ended up moving the script in the header and it’s working now but what if the script is only to be displayed in a certain page? Are there plugins for including scripts in specific pages or is there another way of doing it?

    Moderator Samuel Wood (Otto)

    (@otto42)

    WordPress.org Admin

    You can use a Template Tag in your theme code to make it only happen on a specific thing.

    Like, if you want it on a “welcome” page, then you can do this:

    <?php if ( is_page( 'welcome' ) ) { ?>
    script things here
    <?php } ?>

    And similar. See Conditional Tags.

    Thread Starter wrip

    (@wrip)

    Thanks. That should do it.

Viewing 6 replies - 1 through 6 (of 6 total)
  • The topic ‘How to escape && in jQuery script?’ is closed to new replies.