Kontakt

Portfolio: Ostryweb @ Instagram.

úterý 12. února 2019

Force refreshing of style changes in Wordpress template (style version as css file attribute)

What we want to achieve is to "force" refreshing of style.css of our template after changes.

Usually this is made by adding template version number as a parameter of the stylesheet, so in the HEAD section the output looks something like this:



If we change 1.0.1 to 1.0.2 browsers should download the new version. Now we want to make it simple, and there is a version parameter already present in any Wordpress theme's style.css in its header part, so why not use that? Logically if we make changes in the stylesheet, we should also increment its version number.

To get the stylesheet HTML output as mentioned above, modify enqueuing of the stylesheet in functions.php like this:



Be aware that you shouldn't have style.css inserted into Wordpress output in any other way. Sometimes it can be "hardcoded" in head.php or other template files.. Check the output HTML if it contains only one line of style.css link tag and that it is the one with the version number...

Žádné komentáře:

Okomentovat