Relative file paths in CSS

I am creating a single-page child theme, in which (apologies to the WordPress community) I am basically trying to stay out of using PHP or the WordPress API as much as possible, because I really just want to deploy a single page with its own scripts and style.

I’m having problems with relative file paths. I have gathered that when it comes to PHP pages I need to use the get_theme_file_uri() function, and that is working fine in my main PHP page (page-my-slug.php). (As a side note, I would prefer to use get_template_directory_uri() but this is giving the parent theme folder. How to get round this?)

But what is the solution for my CSS file (eg. for images)? This page suggests I should just be able to insert relative links in there, but that’s not working for me.

What am I doing wrong? I wonder if it has something to do with the fact that I have linked my CSS directly rather than enqueued it… (Again, I’m sorry for abusing WordPress but for my purposes enqueuing would really overcomplicate things.)

Read more here:: Relative file paths in CSS

Leave a Reply

Your email address will not be published. Required fields are marked *