0

Recently i m transfering my site to wordpress and while doing it i m enqueuing javascripts in my wordpress footer through function,php but it not loading in browser .

my function.php codes :

function NewBiz_scripts() {

    wp_enqueue_style( 'style', get_stylesheet_uri() );
    wp_enqueue_script( 'script', get_template_directory_uri() . '/js/main.js', array ('jquery'), NULL ,true);
    wp_enqueue_style( 'animate',get_template_directory_uri() . '/lib/animate/animate.css' );
    wp_enqueue_style( 'animate-min',get_template_directory_uri() . '/lib/animate/animate.min.css' );
    wp_enqueue_style( 'bootstrap',get_template_directory_uri() . '/lib/bootstrap/css/bootstrap.css' );
    wp_enqueue_style( 'bootstrap.min',get_template_directory_uri() . '/lib/bootstrap/css/bootstrap.min.css' );
    wp_enqueue_script('bootstrap-js-bundle' . get_template_directory_uri() . '/lib/bootstrap/js/bootstrap.bundle.min.js',array(),NULL,true);
    wp_enqueue_script('bootstrap-js-min' . get_stylesheet_uri() . '/lib/bootstrap/js/bootstrap.min.js',NULL,true);
    wp_enqueue_script('counterup' . get_template_directory_uri() . '/lib/counterup/counterup.js', NULL, NULL ,true);
    wp_enqueue_script('easing' . get_template_directory_uri() . '/lib/easing/easing.js', NULL, NULL ,true);
    wp_enqueue_script('easing.min' . get_template_directory_uri() . '/lib/easing/easing.min.js' , NULL,NULL , true);
    wp_enqueue_style ('font-awesome' . get_template_directory_uri() . '/lib/font-awesome/css/font-awesome.css');
    wp_enqueue_style ('font-awesome.min'. get_template_directory_uri() . '/lib/font-awesome/css/font-awesome.min.css');
    wp_enqueue_style ('ionicons' . get_template_directory_uri() . '/lib/ionicons/css/ionicons.css');
    wp_enqueue_style ('ionicons.min' . get_template_directory_uri() . '/lib/ionicons/css/ionicons.min.css');
    wp_enqueue_script('mobile-nav' . get_template_directory_uri () . '/lib/mobile-nav/mobile-nav.js',NULL, NULL , true);
    wp_enqueue_script('jquery' . get_template_directory_uri() . '/lib/jquery/jquery.min.js',array () ,NULL ,NULL ,true );
    wp_enqueue_script('jquery_migrate' . get_template_directory_uri() . '/lib/jquery/jquery-migrate.min.js',array() ,NULL ,NULL ,true );



}   

add_action( 'wp_enqueue_scripts', 'NewBiz_scripts' );
?>

<?php
$theme_name_images = get_bloginfo('stylesheet_directory') . '/img/';
?>

only main.js is loading rest not loading .

screenshot DOM

please some one can help me to figure out what i m doing wrong i new to wordpress. thankyou.

2
  • can you please tell me where you added this code In child theme or parent theme ? Commented Nov 21, 2019 at 12:11
  • @BhAvikGajjar i added this code to parent theme. Actually i m converting a html site to wordpress. Commented Nov 21, 2019 at 16:35

2 Answers 2

1

jQuery is already inside WordPress so you don't need to add jQuery again and if you are including minified version .min then you don't need to include the full version. I have commented the repeating files. You also made a mistake enqueue where you added . instead of , I have edited your code so try this code. It should work.

function NewBiz_scripts() {

    wp_enqueue_style( 'style', get_stylesheet_uri() );
    wp_enqueue_script( 'script', get_template_directory_uri() . '/js/main.js', array ('jquery'), NULL ,true);
//    wp_enqueue_style( 'animate',get_template_directory_uri() . '/lib/animate/animate.css' );
    wp_enqueue_style( 'animate-min',get_template_directory_uri() . '/lib/animate/animate.min.css' );
//    wp_enqueue_style( 'bootstrap',get_template_directory_uri() . '/lib/bootstrap/css/bootstrap.css' );
    wp_enqueue_style( 'bootstrap-min',get_template_directory_uri() . '/lib/bootstrap/css/bootstrap.min.css' );
    wp_enqueue_script('bootstrap-js-bundle', get_template_directory_uri() . '/lib/bootstrap/js/bootstrap.bundle.min.js',array ('jquery'),NULL,true);
//    wp_enqueue_script('bootstrap-js-min', get_template_directory_uri() . '/lib/bootstrap/js/bootstrap.min.js',array ('jquery'),true);
    wp_enqueue_script('counterup', get_template_directory_uri() . '/lib/counterup/counterup.js', array ('jquery'), NULL ,true);
    wp_enqueue_script('easing', get_template_directory_uri() . '/lib/easing/easing.js', array ('jquery'), NULL ,true);
    wp_enqueue_script('easing-min', get_template_directory_uri() . '/lib/easing/easing.min.js' , array ('jquery'),NULL , true);
//    wp_enqueue_style ('font-awesome', get_template_directory_uri() . '/lib/font-awesome/css/font-awesome.css');
    wp_enqueue_style ('font-awesome-min', get_template_directory_uri() . '/lib/font-awesome/css/font-awesome.min.css');
//    wp_enqueue_style ('ionicons', get_template_directory_uri() . '/lib/ionicons/css/ionicons.css');
    wp_enqueue_style ('ionicons-min', get_template_directory_uri() . '/lib/ionicons/css/ionicons.min.css');
    wp_enqueue_script('mobile-nav', get_template_directory_uri () . '/lib/mobile-nav/mobile-nav.js',array ('jquery'), NULL , true);
//    wp_enqueue_script('jquery', get_template_directory_uri() . '/lib/jquery/jquery.min.js',array () ,NULL ,NULL ,true );
//    wp_enqueue_script('jquery_migrate' . get_template_directory_uri() . '/lib/jquery/jquery-migrate.min.js',array() ,NULL ,NULL ,true );



}   

add_action( 'wp_enqueue_scripts', 'NewBiz_scripts' );
?>

<?php
$theme_name_images = get_bloginfo('stylesheet_directory') . '/img/';
?>
Sign up to request clarification or add additional context in comments.

Comments

0

do you have wp_footer hook called in your theme template?

wp_footer();

it's usually located in the theme footer.php it's required by WordPress wp_enqueue_script because otherwise the place to add the scripts to would be missing.

Best, Sebo

Comments

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service and acknowledge you have read our privacy policy.

Start asking to get answers

Find the answer to your question by asking.

Ask question

Explore related questions

See similar questions with these tags.