![]() Never send requests directly to your plugin pages. The other is that all AJAX requests need to be sent through wp-admin/admin-ajax.php. One is the need to enqueue scripts in order to get meta links to appear correctly in the page’s head section. This section covers the two major quirks of AJAX in WordPress that trip up experienced coders new to WordPress. Second is the actual handling of the AJAX request. First we need to enqueue the jQuery script on the web page and localize any PHP values that the jQuery script needs. If you’re interested in how to pass data for the JavaScript files enqueued with wp_enqueue_script(), please see this post.There are two parts to the server side PHP script that are needed to implement AJAX communication. ![]() 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 |