Additionally, we must use wp_localize_script() to pass values into JavaScript object properties, since PHP cannot directly echo values into our JavaScript file. You cannot run this script on the current system. NOTE When a constructor creates an object, that object implicitly references the constructors prototype property for the purpose of resolving property references. For example, a Theme named "test" would reside in the directory wp-content/themes/test/. WordPress Video Tutorials WPBeginners WordPress 101 video tutorials will teach you how to create and manage your own site(s) for FREE. If you’re interested in how to pass data for the JavaScript files enqueued with wp_enqueue_script(), please see this post.Explore our samples and discover the things you can build. That should be pretty much all the information you’d need to have to start using wp_enqueue_script() function. Wp_enqueue_style( 'wpa-main-css', get_theme_file_uri( 'dist/styles/main.css' ),, filemtime( get_theme_file_path( 'dist/styles/main.css' ) ) ) There’s actually almost identical function to wp_enqueue_script() called wp_enqueue_style() that allows you to enqueue css files. Wp_enqueue_script( 'wpa-main-js', get_theme_file_uri( 'dist/scripts/main.js' ),, filemtime( get_theme_file_path( 'dist/scripts/main.js' ) ), true ) Īdd_action( 'wp_enqueue_scripts', 'wpa_enqueue_scripts', 100 ) Use wp_enqueue_style() for css files Luckily it’s pretty easy to bust a cache with the timestamp of the js file:
0 Comments
Leave a Reply. |
AuthorWrite something about yourself. No need to be fancy, just an overview. ArchivesCategories |