Tag Info

Hot answers tagged

6

You're mixing up the singular wp_enqueue_script, which adds a script, with the plural wp_enqueue_scripts which is an action and a function that triggers that action. I think you want function theme_scripts() { wp_enqueue_script( 'custom-script', get_template_directory_uri() . '/js/menu-fix.js', array('jquery'), '1.0', true); } ...


2

Try to remove this from footer.php <script src="https://ajax.googleapis.com/ajax/libs/jquery/1.11.1/jquery.min.js"></script> And One tip: Use wp_enqueue_script to load all JS on your web page.


2

Use in_array(): if ( in_array( $hook, [ 'user-edit.php', 'profile.php' ] ) ) // do something Or wait for the action personal_options, and enqueue the script for the footer. This action is fired in both cases. See this old example.


2

My guess would be that you are remove the action before it is actually being added in the parent theme. The parent's theme functions.php file gets loaded after the child one so it looks like your removing something that is not there yet. The 3rd parameter in remove_action() is the priority. Try playing around with that number - the default is 10 - to see ...


1

OK, you have two problems here. Firstly, you are enqueueing your style with wp_enqueue_script(), which is meant to be used by scripts. You should be using wp_enqueue_style Secondly, you need to understand what functions are loaded when. Plugins are loaded first, child themes second and parent themes last. So you styles gets loaded first, and then the ...


1

The dependencies are case-sensitive - you need array( 'jquery' ) (no uppercase Q).


1

A couple issues here... First, the init hook is too early for WordPress to know which page template you're going to be using. (So the is_page_template() function will always return false). Just go ahead and hook your function to wp_enqueue_scripts (which you're probably already doing for your global CSS / JavaScript). And then check for the page template ...


1

I'd probably try only enqueueing those scripts on specific pages, rather than enqueuing and then dequeuing them: function wpse158453_enqueue_scripts() { if(!is_page('my-page')) { wp_enqueue_script( 'jquery', '//ajax.googleapis.com/ajax/libs/jquery/1.11.1/jquery.min.js' ); wp_enqueue_script( 'jquery-ui', ...


1

You have a basic mistake in your code. The following code if ( !is_page('my-page') ) { means that if you are not on that page, deregister the scripts. Have a look at the php operators ! -> Not !$x True if $x is not true Also, why not exclude this specific page when you initially enqueue these scripts, something like add_action( ...



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