![]() ![]() Hope this helps someone, and thanks to for pointing me in the right direction. So the parent style shows the version listed in its file: 1.0.17Īnd the child style shows the version derived from the creation time/date of the file itself: 1617237081 Wp_enqueue_style( 'child-style', get_stylesheet_uri(),įilemtime( $themecsspath ) // this replaces the get('Version') line $themecsspath = get_stylesheet_directory(). Wp_enqueue_style( $parenthandle, get_template_directory_uri(). For anyone interested, I used the second code listed on the Child Themes page, and modified the second part: add_action( 'wp_enqueue_scripts', 'my_theme_enqueue_styles' ) So I changed it to the current way, but that didn’t help with what I needed, which is to add the time/date as a version number.īut with this new information, I was able to find the correct keywords to google the solution. Before that it was something like in the child theme’s stylesheet to import the parent stylesheet. ![]() The code I posted is what they had when I made the site, maybe five years ago. I don’t know what I am doing, so I always go to that Child Theme page on WordPress to follow the steps. It seems as if every time I create a child theme, the rules are different. I’m assuming there is a way to incorporate the first code with the second, but the second appears to only call the parent stylesheet, so I’m lost now as to how to apply this automated versioning to the child stylesheet. Wp_enqueue_style( 'parent-style', get_template_directory_uri(). This is what is in my child theme’s functions.php regarding stylesheets: add_action( 'wp_enqueue_scripts', 'theme_enqueue_styles' ) Though the name’s a little weird, it basically just means tell WordPress to load a stylesheet. wpenqueuestyle is a common example of just such a WordPress-provided function. " type="text/css" media="screen, projection" /> If you’re new to WordPress development, you may not be super familiar to the concept of WordPress specific functions. So what can I do with this magic code that works so well? This is the code I put in my header.php: ![]() And I just read that you shouldn’t put anything after wp_head except the closing head tag. It’s only just now that I am realizing it’s loading the css twice. I couldn’t find the code that calls the child theme stylesheet, so assumed it is called by wp_head, so placed this new code after that, knowing it would load the latest css. So I found code online that will automatically change the version number, based on the save date/time, I think. wpenqueuestyle( handle, src, deps, ver, media ) Top. One solution is to change the version number on the stylesheet, but I can never remember to do that, after various minor tweaks. A safe way to add/enqueue a stylesheet file to the WordPress generated page. Unfortunately, that is not an available option on my iPhone, so it’s difficult to see if the changes I made work there. After changing something in css, I will go to the page and do a force-reload (CTRL+F5) to make it reload the stylesheet so I can see if it worked. ![]()
0 Comments
Leave a Reply. |
AuthorWrite something about yourself. No need to be fancy, just an overview. ArchivesCategories |