Viewing 9 replies - 1 through 9 (of 9 total)
  • The GitHub link you shared for your theme isn’t accessible. For including JS files, try using wp_enqueue_script() in your functions.php.

    function my_custom_script() {
    wp_enqueue_script( 'registered-script', get_template_directory_uri() . '/js/my-script.js', array(), '1.0', true );
    }
    add_action( 'wp_enqueue_scripts', 'my_custom_script' );

    This will properly load your JavaScript file at the bottom of your HTML, which is generally a good practice.

    I took a look at the view-source of your site, and I noticed something important: your JS files are being hard-coded with relative paths rather than using WordPress functions. This explains the behavior you’re seeing!

    When you use relative paths in WordPress, they’re relative to the site root, not your theme directory. That’s why you’re seeing URLs like https://learning-test.local/js/plugins/swiper.min.js instead of https://learning-test.local/wp-content/themes/TERAFORMED/js/plugins/swiper.min.js.

    Thread Starter roadreaper

    (@roadreaper)

    Oh im sorry i didn’t make it public also i did enqueue the links but it still doesn’t work

    you should remove the hardcoded js scripts

    Try using jQuery(document).ready(function ($) { in your main.js file

    This way, $ will be recognized as the jQuery function within that scope. And i tried it and it worked

    Also, you need to fix the image links in your HTML(index.php). Currently, they’re using relative paths like this

    <img src="img/blog/1.jpg" alt="cover">

    You should change them to use the correct WordPress functions, like this

    <img src="<?php echo get_theme_file_uri('/img/blog/1.jpg'); ?>" alt="cover">
    Thread Starter roadreaper

    (@roadreaper)

    thanks for looking it up, there are no static links as you can see neither in my main.php nor my footer.php I don’t know how you are seeing them like that

    Thread Starter roadreaper

    (@roadreaper)

    Yeah the images are something i will fix but why are the scripts not loading

    The scripts are loading correctly, but there’s an error in your main.js file located in the js folder. It shows “Uncaught TypeError: $ is not a function” for this line. This issue likely arises because WordPress uses jQuery in no-conflict mode by default, meaning the $ shortcut may not be available unless you explicitly use it in a jQuery context.

    To fix this, you can either use jQuery directly, or wrap your code like this:

    jQuery(document).ready(function ($) {
    // Your code here
    });
Viewing 9 replies - 1 through 9 (of 9 total)
  • You must be logged in to reply to this topic.