get_theme_file_uri does not work for scripts…

[ad_1]

Im trying to turn a web template into a static theme and get_theme_file_uri resolves in the url/the files instead of wp-content/themes/thetheme/js/plugins/swiper.min.js

so instead of looking for the file here:
http://learning-test.local/wp-content/themes/TERAFORMED/js/plugins/swiper.min.js

it looks for the file here:
http://learning-test.local/js/plugins/swiper.min.js

However when i log it in the debug file i see it resolves to http://learning-test.local/wp-content/themes/TERAFORMED/js/plugins/swiper.min.js

https://preview.redd.it/t2i8v84adnsd1.png?width=1916&format=png&auto=webp&s=770bf721187b6fb281d5b013d9480793e58a1168

this is my functions.php:

<?php



/**
 * Teraformed Theme Functions
 *
 * This file enqueues scripts, styles, and handles various
 * functionality for the theme.
 *
 * @package Teraformed
 */




function enqueue_custom_styles_and_scripts() {
    
    error_log('Theme directory URI: ' . get_template_directory_uri('/js/plugins/swiper.min.js'));
    error_log('Theme file URI: ' . get_theme_file_uri('/js/plugins/swiper.min.js'));

    
    wp_enqueue_style('bootstrap-grid', get_theme_file_uri('/css/plugins/bootstrap-grid.css'));
    wp_enqueue_style('font-awesome', get_theme_file_uri('/css/plugins/font-awesome.min.css'));
    wp_enqueue_style('swiper', get_theme_file_uri('/css/plugins/swiper.min.css'));
    wp_enqueue_style('fancybox', get_theme_file_uri('/css/plugins/fancybox.min.css'));
    wp_enqueue_style('main-style', get_theme_file_uri('/css/style.css'));

   
    if (!file_exists(get_theme_file_path('/css/style.css'))) {
        error_log('CSS file does not exist: ' . get_theme_file_path('/css/style.css'));
    }

    
    wp_enqueue_script('jquery');

   
    wp_enqueue_script('main-js', get_theme_file_uri('/js/main.js'), array('jquery'), null, true);
    wp_enqueue_script('swup', get_theme_file_uri('/js/plugins/swup.min.js'), array('jquery'), null, true);
    wp_enqueue_script('swiper', get_theme_file_uri('/js/plugins/swiper.min.js'), array('jquery'), null, true);
    wp_enqueue_script('fancybox', get_theme_file_uri('/js/plugins/fancybox.min.js'), array('jquery'), null, true);
    wp_enqueue_script('gsap', get_theme_file_uri('/js/plugins/gsap.min.js'), array('jquery'), null, true);
    wp_enqueue_script('smooth-scroll', get_theme_file_uri('/js/plugins/smooth-scroll.js'), array('jquery'), null, true);
    wp_enqueue_script('scroll-trigger', get_theme_file_uri('/js/plugins/ScrollTrigger.min.js'), array('jquery'), null, true);
    wp_enqueue_script('scroll-to', get_theme_file_uri('/js/plugins/ScrollTo.min.js'), array('jquery'), null, true);
   

    
    if (!file_exists(get_theme_file_path('/js/main.js'))) {
        error_log('JS file does not exist: ' . get_theme_file_path('/js/main.js'));
    }
}

add_action('wp_enqueue_scripts', 'enqueue_custom_styles_and_scripts');




function check_if_child_theme() {
    if (is_child_theme()) {
        error_log('A child theme is active.');
    } else {
        error_log('No child theme is active. Using the parent theme.');
    }
}

add_action('after_setup_theme', 'check_if_child_theme');



?>

here are my theme files on my local by flywheel:

https://preview.redd.it/c4ovzlsldnsd1.png?width=1252&format=png&auto=webp&s=c117ea82c1f33d49e962827b4aa05ea39829e44e

it also doesn't work on a hosting…

I am speechless this looks impossible to be happening according to chatgpt and claude(im new to wordpress development), here is the js: https://jsfiddle.net/aLkey8n6/ as far as i see there is nothing here that should be affecting anything regarding urls… does this look impossible only to me?

[ad_2]

 

This site will teach you how to build a WordPress website for beginners. We will cover everything from installing WordPress to adding pages, posts, and images to your site. You will learn how to customize your site with themes and plugins, as well as how to market your site online.

Buy WordPress Transfer