Should I use wp_register_style(), wp_enqueue_style, or both?
Should I use wp_register_style(), wp_enqueue_style, or both?
Should I use wp_register_style(), wp_enqueue_style, or both?
Warning: filemtime(): stat failed for wp_
The fix was really easy. The template I was trying to load, did not have wp_head() in it. So ofcourse no JS/CSS was loading in. Thanks for the help everyone!
The id attribute was added to the <style> tags in WordPress v4.1 (2014) — see the Trac changesets 29956 and 29958 which both mentioned ticket #30032 (“Add ID attribute to style element from wp_add_inline_style()“): In order to support partial preview refreshes (#27355), it is important for all partials being updated to have an element with … Read more
That’s part of the default functionality available in wp_enqueue_script/wp_register_script. The third argument, as seen in the official documentation of enqueue/register script, https://developer.wordpress.org/reference/functions/wp_enqueue_script/, https://developer.wordpress.org/reference/functions/wp_register_script/, is the dependencies array. $deps string[] Optional An array of registered script handles this script depends on. Default: array() So lets say you have script with the handle “sliderjs”, using your code … Read more
WordPress does not register a script with the handle jquery-ui by default, and it will skip printing the markup for any enqueued script for which it is unable to resolve all dependencies at the time of printing. So unless you or another extension is registering or enqueuing a script with the jquery-ui handle, your script … Read more
As the “Error Message” (which is in fact a “doing it wrong”-message) is telling you, you’re using the wrong hook: Scripts and styles should not be registered or enqueued until the wp_enqueue_scripts, admin_enqueue_scripts, or login_enqueue_scripts hooks. Just read about hooks, wrap your code in a callback and then register it properly on one of the … Read more
If you want to enqueue the scripts only on the “Events” page, change the following code to include the conditional tag is_page() function public_enqueue() { //Scripts wp_enqueue_script(‘events-manager’, plugins_url(‘includes/js/events-manager.js’,__FILE__), array(‘jquery’, ‘jquery-ui-core’,’jquery-ui-widget’,’jquery-ui-position’,’jquery-ui-sortable’,’jquery-ui-datepicker’,’jquery-ui-autocomplete’,’jquery-ui-dialog’)); //jQuery will load as dependency //Styles wp_enqueue_style(‘events-manager’, plugins_url(‘includes/css/events_manager.css’,__FILE__)); //main css } Change it to the following: function public_enqueue() { if( is_page(‘events’) ) { //Only load … Read more
The reason being that: get_template_directory_uri() actually returns the parent’s theme url. To fix it, I simply concatenated the remainder of the path. In this case, the code became: // loading menu toggle function | located in the child’s theme folder function menu_toggle_enqueue_script() { wp_enqueue_script( ‘menu-toggle’, get_template_directory_uri(). ‘-child’ . ‘/assets/js/menu.js’); } add_action(‘wp_enqueue_scripts’, ‘menu_toggle_enqueue_script’); I figured out … Read more
Your code is correct, but you will not see this <script> tag in your header! The last parameter of wp_enqueue_script() is a flag regarding whether or not to load the script at the bottom of the page. You have this set to true, so you’re telling WordPress to create a <script> tag at the bottom … Read more