Click here to Skip to main content
15,887,027 members
Please Sign up or sign in to vote.
0.00/5 (No votes)
<link rel="stylesheet" type="text/css" href="<?php bloginfo('stylesheet_url'); echo '?ver=' . filemtime( get_stylesheet_directory() . '/style.min.css'); ?>" media="screen" />

Keeps returning style.css.

How do I make it return style.min.css? Reminder: I want to be able to do this within the head tag, not within functions. Thanks

What I have tried:

I have tried
<link rel="stylesheet" type="text/css" href="<?php bloginfo('stylesheet_url'); echo '?ver=' . filemtime( get_stylesheet_url() . '/style.min.css'); ?>" media="screen" />

Replacing 'get_stylesheet_directory' with 'get_stylesheet_url' definitely did not work, it erased everything underneath the <link>
Posted
Updated 3-Mar-16 17:55pm

Hi,

bloginfo('stylesheet_url') will return theme's stylesheet path like
http://example.com/wp-content/themes/YOUR_ACTIVE_THEME/style.css

But everytime you are getting the filemtime(file modified time) of style.min.css file. Instead of this you should write the following code:
<link rel="stylesheet" type="text/css" href="<?php bloginfo('stylesheet_url'); echo '?ver=' . filemtime( get_stylesheet_directory() . '/style.css'); ?>" media="screen" />


Now it must work when you modify your style.css file.

Hope this will work for you!
 
Share this answer
 
v3
Comments
Member 12357126 1-Mar-16 4:59am    
Hi zapbuild, thanks for taking the time to help me out - much appreciated! I am aware that the code you wrote will works when I modify the style.css, but I want it to work for style.min.css. When I put style.min.css the code keeps returning style.css. I want it to return style.min.css
Hi,

bloginfo('stylesheet_url') will return theme's stylesheet path of style.css file not style.min.css file, if you want to use the style.min.css file then you can use the following code:

<link rel="stylesheet" type="text/css" href="<?php echo bloginfo('stylesheet_directory').'/style.min.css'; echo '?ver=' . filemtime( get_stylesheet_directory() . '/style.min.css'); ?>" media="screen" />
 
Share this answer
 

This content, along with any associated source code and files, is licensed under The Code Project Open License (CPOL)



CodeProject, 20 Bay Street, 11th Floor Toronto, Ontario, Canada M5J 2N8 +1 (416) 849-8900