Where is my mistake in the wp_enqueue_script?

134 Views Asked by At

I'm doing a portfolio. I didn't want to loose a lot of time but as newbie this is still difficult for me so i challenge myslef. So i took a template bootstrap and I want to 'import' the template on my wordpress website.

I used the wp_enqueue_script to link my css and js to my page. Here the code in the function.php :

unction portoflio_theme_bootstrap_scripts() {

wp_enqueue_style( 'bootstrap', get_template_directory_uri() .'/assets/vendor/bootstrap/css/bootstrap.min.css', array());
wp_enqueue_style( 'bootstrap-icons', get_template_directory_uri() .'/assets/vendor/bootstrap-icons/bootstrap-icons.css', array());
wp_enqueue_style( 'boxicons', get_template_directory_uri() .'/assets/vendor/boxicons/css/boxicons.min.css', array());
wp_enqueue_style( 'glightbox', get_template_directory_uri() .'/assets/vendor/glightbox/css/glightbox.min.css', array());
wp_enqueue_style( 'swiper', get_template_directory_uri() .'/assets/vendor/swiper/swiper-bundle.min.css', array());
wp_enqueue_style( 'main-style', get_template_directory_uri() .'/assets/css/style.css', array());

    wp_enqueue_script( 'purecounter', get_template_directory_uri() . '/assets/vendor/purecounter/purecounter_vanilla.js', array());
    wp_enqueue_script( 'bootstrap-js', get_template_directory_uri() . '/assets/vendor/bootstrap/js/bootstrap.bundle.min.js', array());
    wp_enqueue_script( 'glightbox', get_template_directory_uri() . '/assets/vendor/glightbox/js/glightbox.min.js', array());
    wp_enqueue_script( 'isotope-layout', get_template_directory_uri() . '/assets/vendor/isotope-layout/isotope.pkgd.min.js', array());
    wp_enqueue_script( 'swiper', get_template_directory_uri() . '/assets/vendor/swiper/swiper-bundle.min.js', array());
    wp_enqueue_script( 'waypoints', get_template_directory_uri() . '/assets/vendor/waypoints/noframework.waypoints.js', array());
    wp_enqueue_script( 'custom-js', get_template_directory_uri() . '/assets/js/main.js', array());


    }

add_action( 'wp_enqueue_scripts', 'portoflio_theme_bootstrap_scripts' );

The css is working but the js not really. I think the js "isotope-layout" is woking because without this file, the section porfolio doesn't work. So, if this js file work, why the others don't work ? I did a mistake somewhere.

Here the link of my one-page portoflio : https://pierre-fayard.com/visual-composer-3615/

I searched and tried a lot of things but nothing is working. If you need more files, tell me. I'm a newbie so maybe i forgot something.

Thank you !

1

There are 1 best solutions below

2
On

You can achieve it without having to mess up function.php.

Download and install this plugin.

Using FTP connection or using File Manager plugin, upload the JS and CSS files accordingly inside the assets folders.

Then, modify plugin.php by adding the JS and CSS enqueue codes inside function custom_enqueue_files() following the sample code format provided.