Tag Info

Hot answers tagged


Enqueueing styles within a function as you have done is the standard best practice for WordPress, whether you are building a theme or creating a child theme. And as mentioned, you can enqueue both styles and scripts from within one function, http://marker.to/65CMY3.


In theory the code you wrote should work, in the practical application you are missing some good practices which it might impact on how your code is working, so it's better run through a bit of troubleshooting to tick off everything from the checklist. By de-registering jquery you are taking away both the jQuery core and the jQuery Migrate javascripts, ...


Have you looked at wp_enqueue_script in the WordPress codex? You'll most likely need to add this to functions.php in your theme's directory. Also, where are you enqueuing the startapp_js dependency? function prefix_enqueue_scripts() { wp_enqueue_script( 'startapp-js', get_template_directory_uri() . '/scripts/Startapp.js', array(), '', true ); ...


No 1: you have to put your jquery deregister etc. Stuff into a function that is called with the wp_enqueue_scripts hook. Do it like this: add_action('wp_enqueue_scripts','jquery_2_loader'); function jquery_2_loader(){ //insert your jquery deregister and Register } Second question: many Plugins rely on enqueuing jquery. So if you deregister it, those ...


Best practice in this case would be to enqueue the js file inside the WP functions.php file. Are the braintree submit pages on their own unique templates? If so you could add something like this to your functions file: function register_scripts() { if(is_page_template('template-parts/page-braintree.php')): wp_register_script( 'braintree-js', ...


You could do it like this: function theme_styles(){ /* * This if() statement is unnecessary, as wp_enqueue_scripts * doesn't fire on the admin pages. * if( is_admin() ) { * return; * } */ wp_enqueue_style( 'theme-styles', get_template_directory_uri() . '/css/all.css', array(), false, ...


Per comments get_stylesheet_directory_uri() gets the current template (child in this case) directory, eg // Load our main stylesheet. wp_enqueue_style( 'less-style', get_stylesheet_directory_uri() . '/css/style.less' );

Only top voted, non community-wiki answers of a minimum length are eligible