[Support request] Add jQuery code, js scripts, css links etc.

Home Forums Support [Support request] Add jQuery code, js scripts, css links etc.

Home Forums Support Add jQuery code, js scripts, css links etc.

Viewing 3 posts - 16 through 18 (of 18 total)
  • Author
    Posts
  • #780999
    Tom
    Lead Developer
    Lead Developer

    It’s not so much the theme, it’s that WordPress itself doesn’t allow <script> tags in the content editor. They do this for security reasons.

    One option is to build a shortcode, which you can then place in your content.

    For example:

    add_shortcode( 'my_ad', function() {
        ?>
            <script>YOUR SCRIPT IN HERE</script>
        <?php
    } );

    Then you can add this to your content area: [my_ad]

    #781056
    Greg

    Sorry, Tom, I appreciate your prompt responses, but
    your code has a problem.
    I tried it directly in the page content. Certainly replaced the “Your script in here” with my script.
    Saved opened the page and … got this text on the screen:
    add_shortcode( ‘my_ad’, function() {
    ?>

    Please correct and update. I agree that this is common to WordPress so there must be plenty of good solutions. You said the suggested code is just one possibility could you be so kind and offer some other options. I am puzzled that we dropped the wp-footer hook topic. I was under the impression from your tutorial video that this is the preferred approach. What am I missing?

    #781101
    Tom
    Lead Developer
    Lead Developer

    That code should be added using one of these methods: https://docs.generatepress.com/article/adding-php/

    Then you can use the shortcode in your content: [my_ad]

Viewing 3 posts - 16 through 18 (of 18 total)
  • You must be logged in to reply to this topic.