Suellyn Specie free asked 7 years ago


I'm working with wordpress and I put this code, but in F12 doesn't show errors. I put the carrousel to test and continue not working. I try to put scripts in after footer too but not working too. CSS is working, just js not working. Please, could you help me? <?php /** * Include CSS files */ function theme_enqueue_scripts() { wp_enqueue_style( 'Font_Awesome', 'https://maxcdn.bootstrapcdn.com/font-awesome/4.6.3/css/font-awesome.min.css' ); wp_enqueue_style( 'Bootstrap_css', get_template_directory_uri() . '/css/bootstrap.min.css' ); wp_enqueue_style( 'MDB', get_template_directory_uri() . '/css/mdb.min.css' ); wp_enqueue_style( 'Style', get_template_directory_uri() . '/style.css' ); wp_enqueue_script( 'jQuery', get_template_directory_uri() . '/js/jquery-2.2.3.min.js', array(), '2.2.3', true ); wp_enqueue_script( 'Tether', get_template_directory_uri() . '/js/tether.min.js', array(), '1.0.0', true ); wp_enqueue_script( 'Bootstrap', get_template_directory_uri() . '/js/bootstrap.min.js', array(), '1.0.0', true ); wp_enqueue_script( 'MDB', get_template_directory_uri() . '/js/mdb.min.js', array(), '1.0.0', true ); } add_action( 'wp_enqueue_scripts', 'theme_enqueue_scripts' ); ?>

This works 100%. The key was to add 'array('jquery'));' to js files in the directory instead of 'array(), '1.1.0', true );'

function theme_enqueue_scripts() {
 wp_enqueue_style( 'Font_Awesome', 'https://maxcdn.bootstrapcdn.com/font-awesome/4.6.3/css/font-awesome.min.css' );
 wp_enqueue_style( 'Bootstrap_css', get_template_directory_uri() . '/css/bootstrap.min.css' );
 wp_enqueue_style( 'MDB', get_template_directory_uri() . '/css/mdb.min.css' );
 wp_enqueue_style( 'Style', get_template_directory_uri() . '/style.css' );
 wp_enqueue_script( 'jQuery', get_template_directory_uri() . '/js/jquery-3.2.1.min.js', array(), '3.2.1', true );
 wp_enqueue_script( 'Tether', get_template_directory_uri() . '/js/tether.min.js',array('jquery'));
 wp_enqueue_script( 'Popper', get_template_directory_uri() . '/js/popper.min.js', array('jquery'));
 wp_enqueue_script( 'Bootstrap', get_template_directory_uri() . '/js/bootstrap.min.js', array('jquery'));
 wp_enqueue_script( 'MDB', get_template_directory_uri() . '/js/mdb.js', array('jquery'));
 wp_enqueue_script('CustomJS', get_template_directory_uri() . '/js/custom-js.js', array('jquery'));
}
add_action( 'wp_enqueue_scripts', 'theme_enqueue_scripts' );

espiran free commented 6 years ago

ashelighmorehattia thanks a lot, bro! your code for wp_enqueue_script worked for me!

Suellyn Specie free answered 7 years ago


Hey Andre! Thank youuuu!!! It's working now!!! Thank yoou so much!!!

Maciej Szuchta free answered 7 years ago


Suellyn Please can you check if solution provided by teawebsite is working for you ?? It looks like there is some issue with scripts linking. If this won't resolve your problem please contact me on m.szuchta@mdbootstrap.com.

Andre Cordeiro free answered 7 years ago


Hi! Please can you check if you have the following line in your footer.php file. <?php wp_footer(); ?>

Pruthul Pradeep A free commented 3 years ago

Thanks man! After hours of googling, this finally saved me. Silly me.. forgot this.


teawebsite pro answered 7 years ago


This is what is working for me: 1- first of all you have to work always with child theme: if you do something wrong or update core theme you don't lose your work. 2- in child theme create a folder (e.g: assets). 3- in assets put all mdb pro files. 4- because WP has its own copy of jquery first deregister jquery and then register your preferred version. 5- in functions.php link all css and js using get_stylesheet_directory_uri() because you are working with child theme. /******* DEREGISTER / REGISTER JQUERY *******/ function my_init() { if (!is_admin()) { wp_deregister_script('jquery'); wp_register_script('jquery', get_stylesheet_directory_uri() . '/assets/js/jquery-3.1.1.min.js', FALSE, '3.1.1', FALSE); wp_enqueue_script('jquery'); } } add_action('init', 'my_init'); /******* ENQUEUE CSS / JS *******/ add_action( 'wp_enqueue_scripts', 'theme_enqueue_styles' ); function theme_enqueue_styles() { wp_enqueue_style( 'Font_Awesome', 'https://maxcdn.bootstrapcdn.com/font-awesome/4.6.3/css/font-awesome.min.css' ); wp_enqueue_style( 'Bootstrap_css', get_stylesheet_directory_uri() . '/assets/css/bootstrap.css' ); wp_enqueue_style( 'MDB', get_stylesheet_directory_uri() . '/assets/css/mdb.min.css' ); wp_enqueue_style( 'Style', get_stylesheet_directory_uri() . '/style.css' ); // your own style wp_enqueue_script( 'Tether', get_stylesheet_directory_uri() . '/assets/js/tether.min.js', array(), '1.0.0', true ); wp_enqueue_script( 'Bootstrap', get_stylesheet_directory_uri() . '/assets/js/bootstrap.min.js', array(), '1.0.0', true ); wp_enqueue_script( 'MDB', get_stylesheet_directory_uri() . '/assets/js/mdb.min.js', array(), '1.0.0', true ); } 6- Bonus trick : add this in functions.php to avoid WP adding <p> tag in blank space (lightbox not works without those functions) remove_filter( 'the_content', 'wpautop' ); remove_filter( 'the_excerpt', 'wpautop' ); Note: all MDB PRO 4.3.2 styles and functions I've tried are working except parallax css Hope this helps.

Suellyn Specie free answered 7 years ago


Hey Maciej! I put this line in my functions.php file, but I don't have this file and folder (inc/theme-setup/theme-enqueue-scripts.php).

Erick Maeda free answered 7 years ago


Why should I have this file 'theme-enqueue-scripts.php' ? It didn't work too :/

Maciej Szuchta free answered 7 years ago


Hey Please can you check if you have the following line in your functions.php file. require_once('inc/theme-setup/theme-enqueue-scripts.php');

Suellyn Specie free answered 7 years ago


Hello Maciej! How are you? Thank for your answer, but I tried to clear web browser cash memory and refresh it (Google chrome ctrl + F5 ) and use code with false, but not working yet. :( Js is not being called also when I use F12 (Network) to inspect.

Erick Maeda free answered 7 years ago


I've changed the lines, however it continues not working :/ Sad but true. (º<º)

Maciej Szuchta free answered 7 years ago


Hello Suellyn Your function looks correct so in this case first solution that might help is to clear web browser cash memory and refresh it (Google chrome ctrl + F5 ). Another solution that might work would be to change versions of attached scripts to boolean value 'false'. So function would look like this:
<?php

/**
* Include CSS files
*/
function theme_enqueue_scripts() {
wp_enqueue_style( ‘Font_Awesome’, ‘https://maxcdn.bootstrapcdn.com/font-awesome/4.6.3/css/font-awesome.min.css’ );
wp_enqueue_style( ‘Bootstrap_css’, get_template_directory_uri() . ‘/css/bootstrap.min.css’ );
wp_enqueue_style( ‘MDB’, get_template_directory_uri() . ‘/css/mdb.min.css’ );
wp_enqueue_style( ‘Style’, get_template_directory_uri() . ‘/style.css’ );
wp_enqueue_script( ‘jQuery’, get_template_directory_uri() . ‘/js/jquery-2.2.3.min.js’, array(), false, true );
wp_enqueue_script( ‘Tether’, get_template_directory_uri() . ‘/js/tether.min.js’, array(), false, true );
wp_enqueue_script( ‘Bootstrap’, get_template_directory_uri() . ‘/js/bootstrap.min.js’, array(), false, true );
wp_enqueue_script( ‘MDB’, get_template_directory_uri() . ‘/js/mdb.min.js’, array(), false, true );

}
add_action( ‘wp_enqueue_scripts’, ‘theme_enqueue_scripts’ );

?>
Hope that it will help.

Erick Maeda free answered 7 years ago


Hi Suellyn, I had faced the same problem when I was developing a theme for WordPress, unfortunately I didn't found a solution to the problem yet :(

Please insert min. 20 characters.

FREE CONSULTATION

Hire our experts to build a dedicated project. We'll analyze your business requirements, for free.

Status

Answered

Specification of the issue

  • ForumUser: Free
  • Premium support: No
  • Technology: General Bootstrap questions
  • MDB Version: -
  • Device: -
  • Browser: -
  • OS: -
  • Provided sample code: No
  • Provided link: No