ronc0011 Posted July 22, 2015 Share Posted July 22, 2015 I’m never altogether sure when something is maybe going on but I think this time it’s just my typing it in wrong.I’m working on some Youtube Wordpress tutorials and I’m having an issue with the script finding the style.css file.Of course the script is is calling a Wordpress function but it is after all written in php. So here’s the function…function nq_styles() {wp_enqueue_style('style', get_stylesheet_uri(style.css));}This function was working until I moved the the style.css fill up one level to its own folder. So now the file resides in css/style.cssSo I change dthe file path in the function to…function nq_styles() {wp_enqueue_style('style', get_stylesheet_uri(css/style.css));}I’ve tried a couple of different structures, for example…/css/style.css or ./css/style.css or even //css/style.cssand nothing seems to be working.What am I missing ? BTW I couldn't get the "Code" button to work Quote Link to comment https://forums.phpfreaks.com/topic/297424-file-path-syntax/ Share on other sites More sharing options...
cyberRobot Posted July 22, 2015 Share Posted July 22, 2015 I assume that the style sheet is stored in the same folder as your theme / child theme. If that's correct, have you tried using get_stylesheet_directory_uri()? More information can be found here: https://codex.wordpress.org/Function_Reference/get_stylesheet_directory_uri Quote Link to comment https://forums.phpfreaks.com/topic/297424-file-path-syntax/#findComment-1517090 Share on other sites More sharing options...
ronc0011 Posted July 22, 2015 Author Share Posted July 22, 2015 Not too sure about that one. Reading up on it, it appears to want a web url i.e. http;//website.com/wp_content/themes/mytheme/css/style.css. Besides I’m working on this locally on my laptop so I guess the URL would be something like http://localhost/wp-4/wp_content/themes/sidebars/css/style.css Anyway I am trying to use a relative folder path As I noted the version where the style.css is in the root theme folder with functions.php and index.php works just fine. It’s when I create a folder “css” in the root theme folder and place the style.css file in that folder. I’m having difficulty getting the syntax correct so It can find the stylesheet. I was kind of hoping someone here might be able to tell me what I’m doing wrong in my coding. I’m sure it must be something to do with how I have formed the path for … get_stylesheet_uri("//css/style.css")); or is it… get_stylesheet_uri(./css/style.css)); or maybe… get_stylesheet_uri(‘//css/style.css’)); or even get_stylesheet_uri(/css/style.css)); I have actually done this successfully once before though as I recall it didn’t appear to work right at first and then suddenly without explanation or reason it started working. Who knows? Is it something I’m missing? Quote Link to comment https://forums.phpfreaks.com/topic/297424-file-path-syntax/#findComment-1517092 Share on other sites More sharing options...
cyberRobot Posted July 22, 2015 Share Posted July 22, 2015 You mentioned that the directory was up one level. Did you try something like the following: wp_enqueue_style('style', get_stylesheet_uri(../css/style.css)); Quote Link to comment https://forums.phpfreaks.com/topic/297424-file-path-syntax/#findComment-1517093 Share on other sites More sharing options...
cyberRobot Posted July 22, 2015 Share Posted July 22, 2015 (edited) Hmm...I just noticed that get_stylesheet_uri() doesn't take any parameters. https://codex.wordpress.org/Function_Reference/get_stylesheet_uri It's just supposed to return the current theme's style sheet. Did you say that the following worked before you moved the style sheet? function nq_styles() { wp_enqueue_style('style', get_stylesheet_uri(style.css)); } Perhaps something has changed in WordPress and the documentation hasn't been updated. Edited July 22, 2015 by cyberRobot Quote Link to comment https://forums.phpfreaks.com/topic/297424-file-path-syntax/#findComment-1517094 Share on other sites More sharing options...
maxxd Posted July 23, 2015 Share Posted July 23, 2015 get_stylesheet_uri() doesn't take parameters. You'll need to do get_stylesheet_uri().'/../css/style.css'; Quote Link to comment https://forums.phpfreaks.com/topic/297424-file-path-syntax/#findComment-1517169 Share on other sites More sharing options...
Recommended Posts
Join the conversation
You can post now and register later. If you have an account, sign in now to post with your account.