Unqueue css file from specific page
Unqueue css file from specific page
Unqueue css file from specific page
Of course I’m unable to answer you exactly, because I don’t see a full functions.php code. You can use wp_enqueue_scripts action hook with both, scripts and styles. Do not call wp_enqueue_script and wp_enqueue_style outside of wp_enqueue_scripts hook. add_action(‘wp_enqueue_scripts’, ‘wp_enqueue_scripts_callback’); function wp_enqueue_scripts_callback(){ wp_enqueue_script( ‘jquery’ ); wp_enqueue_script( ‘thickbox’ ); wp_enqueue_script( ‘media-upload’ ); wp_enqueue_script(‘smoothscroll’, get_bloginfo(‘stylesheet_directory’).’/includes/js/smoothscroll.js’, array(‘jquery’), ”); wp_enqueue_script(‘marker’, … Read more
Filter enqueued styles and scripts
You can use is_page_template(‘template.php’) and just replace template.php with your template name.
You don’t need to enqueue jQuery if you enqueue ThickBox already. See this answer for details. thickbox.css gets called, jquery.js also. thickbox.js doesn’t. Lots of missing details: When do you call the function? Is there markup in the HTML output of your page? A script element for ThickBox? If so, do you get a 404 … Read more
Because that is the signature of that particular function. If you don’t like it, you can always use a wrapper function like the one below. function wpse61783_enqueue_script( $handle, $src ) { wp_enqueue_script( $handle, $src, array(), ”, true ); }
You only register your first script, but don’t enqueue it. Change wp_register_script to wp_enqueue_script and it should work. Registering it is useful if you may possibly enqueue it at different times/conditions, but in this case you can just enqueue it straight away.
You could use anonymous functions in PHP 5.3+ to do this. <?php function addThemeJS($enqueueThemeJS, $handle, $src, $deps, $ver, $in_footer) { add_action(‘wp_enqueue_scripts’, function() use ($handle, $src, $deps, $ver, $in_footer) { wp_enqueue_script($handle, $src, $deps, $ver, $in_footer); }); } If you’re using this a personal project where you know the server has 5.3+ you would be okay if … Read more
May be try get_template_directory_uri() instead of get_stylesheet_directory_uri(), if your js file is in your theme, it should work frontend. little help I know^^
Try passing array() for $deps, and NULL for $ver: wp_enqueue_script( $handle, $src, array(), NULL, $in_footer); Or, using your function call: wp_enqueue_script(“myscript” , get_template_directory_uri().”/js/myscript.js”, array(), NULL, true ); By the way, passing the script itself as a dependency to itself will probably make something blow up. Note also: if your script depends on jQuery, just pass … Read more