Plugin Development – Class Constructor Not Firing wp_enqueue_style action hook
There is no action called wp_enqueue_script, it’s wp_enqueue_scripts, plural, and both scripts and styles should be enqueued on that action.
There is no action called wp_enqueue_script, it’s wp_enqueue_scripts, plural, and both scripts and styles should be enqueued on that action.
You can set the priority in hook. Priority is the 3rd parameter in the hook. In the following example, wp_enqueue_scripts will have priority of 99 which is higher than normal priority. Default priority is 10. So it will load at last function load_last_style() { wp_enqueue_style( ‘style-name’, get_stylesheet_uri() ); } add_action( ‘wp_enqueue_scripts’, ‘load_last_style’, 99 );
For google maps in a template file, I just do this: wp_register_script( ‘google-maps-api’, ‘http://maps.google.com/maps/api/js’ ); wp_print_scripts( ‘google-maps-api’ );
get_stylesheet_uri() loads the main stylesheet of the theme. If you need to load additional stylesheets, you need to use get_template_directory_uri() for parent themes and get_stylesheet_directory_uri() for child themes. If you have stylesheet called custom.css in the root in a child theme, you will use get_stylesheet_directory_uri()’ . /custom.css’ You should also make sure that you have … Read more
Hard to tell exactly what’s happening without checking your code, but if you inspect your home page, you’ll see that the video element is being added outside the BODY tag (check attachment below). That might be the reason your script can’t find the video source.
You could add the script that needs to go first as a requirement of the second one. Something like this: wp_register_script(‘myapp’, get_template_directory_uri() . ‘/myapp.js’, array(‘vendors’), ‘20151006’, true);
You can enqueue all your scripts the same way as you enqueue jQuery. Register and enqueue all your Javascripts like this (in your load_jquery function) wp_register_script ( ‘yourscripthandle’, //string $handle: a string to identify this script get_bloginfo( ‘template_url’ ) . ‘/js/yourcustomjs.js’, //string $src: Path of your script file array (‘jquery’ ), // array $deps = … Read more
Could you not just pass the different string? wp_script_add_data( ‘foo’, ‘conditional’, ‘(gt IE 6)&(lt IE 9)’ ); Which by the way is probably the same as: wp_script_add_data( ‘foo’, ‘conditional’, ‘(IE 7)|(IE 8)’ ); IE conditionals are pretty unreliable so need to be tested.
There are no errors in your code shown above and I’ve double checked to see it working correctly in a fresh WP install. It should not be the cause of your errors. A white screen is usually any error but it’s not printed to the screen. Take a look at the DEBUG section of the … Read more
The priority is related to other actions for the same hook. For example, if another plugin would implement add_action for wp_enqueue_scripts with a lower priority, they would have their scripts loaded in front of yours. You should check what scripts are inserted above yours and see if there is a css conflict.