• I’m trying to customize my homepage by creating a page template from scratch, but I’m having trouble getting my PHP file to recognize my external JS file.

    I’ve uploaded three files to my server: a PHP file with my HTML, a CSS file, and and JS/jQuery file. I can get the PHP file to recognize my CSS, but it doesn’t seem to be acknowledging my JavaScript (even though I have the file in the same location as the CSS file).

    Is there anyone who can help me come up with some ways to troubleshoot this problem? I’ve tried everything I can think of.

Viewing 1 replies (of 1 total)
  • Moderator bcworkz

    (@bcworkz)

    You should be using wp_enqueue_script() from within the correct action hook callback. Be sure to specify ‘jquery’ as a dependency. This will result in the correct meta link references being added to the head section of your page. The script for this can be placed in your functions.php file, preferably the one for a child theme.

    Your CSS file should similarly be referenced with wp_enqueue_style().

Viewing 1 replies (of 1 total)
  • The topic ‘Can't get my custom template to recognize my external JavaScript file.’ is closed to new replies.