0

Wordpress beginner here. I created a child theme and I'm trying to enqueue Bootstrap 4 inside the functions.php file. From my understanding, if I want to enqueue Bootstrap properly I need to enqueue the latest version of jQuery first. I believe the parent theme is running an older version of jQuery because I see jQueryUI files like core.min.js?ver=1.11.4 in wp-includes/js/jquery/ui, so I use wp_deregister_script( 'jquery' ); then enqueue the latest version of jQuery. My functions.php code is below

<?php

function kloe_freelance_enqueue_styles() {
    wp_enqueue_style( 'parent-style', get_template_directory_uri() . '/style.css' );
    wp_enqueue_style( 'main-css', get_stylesheet_directory_uri() . '/style.css' );
    wp_enqueue_style( 'bootstrap-css', 'https://maxcdn.bootstrapcdn.com/bootstrap/3.3.7/css/bootstrap.min.css');
}

add_action( 'wp_enqueue_scripts', 'kloe_freelance_enqueue_styles' );

function kloe_freelance_enqueue_scripts(){
    wp_deregister_script( 'jquery' );
    wp_register_script( 'jquery', 'https://code.jquery.com/jquery-3.2.1.min.js');

// popper.js is enqueued because Bootstrap 4 requires it to work. 

wp_enqueue_script('popper_js','https://cdnjs.cloudflare.com/ajax/libs/popper.js/1.11.0/umd/popper.min.js');
    wp_enqueue_script( 'bootstrap_js', 'https://maxcdn.bootstrapcdn.com/bootstrap/3.3.7/js/bootstrap.min.js');

}

add_action( 'wp_enqueue_scripts', 'kloe_freelance_enqueue_scripts');

?>

When I run my website, I get a blank screen. According to the console, I'm getting these errors.

enter image description here

Why am I getting a blank screen? I think I'm getting the blank screen because the latest version of jQuery is incompatible with the parent theme's js files (modules.min.js, like.min.js), but I'm not sure.

2

It does look like some compatability issues are present. There is an answer to a very similar situation on stack exchange here:

https://stackoverflow.com/questions/37738732/jquery-3-0-url-indexof-error

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service, privacy policy and cookie policy

Not the answer you're looking for? Browse other questions tagged or ask your own question.