• rhender

    (@rhender)


    Hello,

    I need to have a javascript code placed only in the <head> of the homepage (home.php).

    Could someone tell me the code to place around that piece of javascript??? I would really really appreciate it. Thank you,

Viewing 5 replies - 1 through 5 (of 5 total)
  • esmi

    (@esmi)

    Thread Starter rhender

    (@rhender)

    Ok, now what if I wanted it on every page in the site?

    How would I write the path to it, so that it worked on every page?

    esmi

    (@esmi)

    Thread Starter rhender

    (@rhender)

    So, I figured out how to place the JavaScript file in the functions.php file…. with the wp_enqueue_script — and so it is “embedded” in the <head> of the website.

    The JavaScript (which controls a form) works great on all of the pages now.

    The form relies on a “get-quote.php” file. There is a link in the JavaScript file for it.

    The only problem is that when I am in a deeper level of the site, the JavaScript works on the form, but when I click the Submit button, the PHP file is not linked up.

    It’s like I need to change the path to the PHP file in the JavaScript file, so that all levels of the site have access to it.

    Unfortunately, I don’t know how to do that. Can anyone help me out with this?

    Thread Starter rhender

    (@rhender)

    Well, I figured this one out. Was easier than I thought.

    All that I needed to do was include an absolute path (https://etc&#8230;) in the JavaScript file, instead of a relative path.

    That allowed every page on my site to have access to the php file, that was linked to in the JavaScript file.

    Now my form works just fine.

Viewing 5 replies - 1 through 5 (of 5 total)
  • The topic ‘need a only in the of the homepage’ is closed to new replies.