• Resolved tibby

    (@tibby)


    Hi

    Hoping someone can help with this.

    I want to add a javascript button to a page which will link to one of 8 random other pages.

    I have the javascript worked out. When I add it in code view on the actual page it shows the button but the button doesn’t work when clicked.

    I believe I may have to have this script enqueued somewhere but all the documentation I am reading relates to making themes or plugins (neither of which I am doing)

    How can I just get this single button to work on this single page?

    This was what I have ready to go into my functions.php

    add_action('wp_enqueue_scripts', 'studydesign_enqueue');
    function studydesign_enqueue() {
        if (is_single('study-display')) {
            wp_enqueue_script(
                'studydesign',
                plugin_dir_url(__FILE__).'study-design-js.js'
            );
        }
    }
    
    

    Any help is gratefully received

Viewing 3 replies - 1 through 3 (of 3 total)
  • Moderator bcworkz

    (@bcworkz)

    Even if you are not developing a theme or plugin, the same code is usually applicable. Please post the contents of study-design-js.js to Pastebin or Gist. Failure of clicks to register can be due to page layout issues, even when it appears correct. If you can, please post a live link to study-display so we can examine the page for possible problems

    Thread Starter tibby

    (@tibby)

    Thanks for your assistance – I solved this issue – the code wasn’t properly saved to functions.php

    Moderator bcworkz

    (@bcworkz)

    No problem. I hate it when that happens, been there, done that 🙂

Viewing 3 replies - 1 through 3 (of 3 total)
  • The topic ‘Javascript buttons not working’ is closed to new replies.