Jump to content

File path syntax ?


ronc0011

Recommended Posts

 

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.css
So 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.css


and nothing seems to be working.

What am I missing ?

 

 

BTW I couldn't get the "Code" button to work

 

Link to comment
Share on other sites

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?

Link to comment
Share on other sites

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 by cyberRobot
Link to comment
Share on other sites

This thread is more than a year old. Please don't revive it unless you have something important to add.

Join the conversation

You can post now and register later. If you have an account, sign in now to post with your account.

Guest
Reply to this topic...

×   Pasted as rich text.   Restore formatting

  Only 75 emoji are allowed.

×   Your link has been automatically embedded.   Display as a link instead

×   Your previous content has been restored.   Clear editor

×   You cannot paste images directly. Upload or insert images from URL.

×
×
  • Create New...

Important Information

We have placed cookies on your device to help make this website better. You can adjust your cookie settings, otherwise we'll assume you're okay to continue.