Auto refreshing styles in WordPress. Code example open

Auto refreshing styles in WordPress. Code example

The idea of this trick is to add ?ver=filetime to the end of the address to the style file.

After each edit of the file, we will get a different time of the file and will change the name of the style file for the browser.

The browser will reload the file.

People won’t crash and won’t have cache problems! Use it

function boxstyle_styles() {
    $style_ver = filemtime( get_stylesheet_directory() . '/style.css' );//we will use a standard php function that will check the time of creating or editing the style file 	 
    wp_enqueue_style( 'boxstyle-style', get_stylesheet_directory_uri() . '/style.css', '', $style_ver );//write this time at the end of the css file
}
0

More

Leave a Reply

Your email address will not be published. Required fields are marked *

How many?: 22 + 22

lil-code© | 2022 - 2024
Go Top
Authorization
*
*
Registration
*
*
*
*
Password generation