1

I am new to wordpress custom theme design. I am trying to access the CSS via functions.php Unfortunately I wrote the php code but when I run it, it display blank screen and all my content are not displaying. The code is here.

<?php
function nanoweb_resources() {
    wp_enqueue_style('style', get_stylesheet_uri());
}
add_action( 'wp_enqueue_scripts', 'nanoweb_resources');

My error is working, I mean if I do anything wrong in code, it display error. According to my half in hour research, some logical error is there. If anyone help me, I will not lose my motivation to learn this big part of custom wordpress themes. Thank you in advance

0

1 Answer 1

1

If your style sheet is not in the root directory of your theme, your second parameter should be the path to the stylesheet. You need to append the name of the stylesheet to the get_template_directory_uri() . '/path/to/sytlesheet.css'. Where /path/to/sytlesheet.css the location of the stylesheet with in the template folder.

Sign up to request clarification or add additional context in comments.

6 Comments

Hello, Yes it is in the root directory. I am learning, so all the files are in root directory. I only one directory root, and index, footer, header, functions and style are there
I'd suggest you use /path/to/stylesheet.css in your answer instead, ie. paths are defined by slashes, then comes the file name, seems more logical to me... just a thought...
Hello, Thank you for support, I created on folder on name css in root directory and rename my css file to stylesheet.css. now it is in the css folder. and I added this to my code wp_enqueue_style('sytle', get_template_directory_uri() . '/css/sytlesheet.css'); how the content is displaying but css is not working
Check your browser's developers tools console for any errors
Good idea Shamar, in consoles I have this error. localhost/design/wp-content/themes/nanowebsytle.css?ver=4.4.2 Failed to load resource: the server responded with a status of 404 (Not Found)
|

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service and acknowledge you have read our privacy policy.

Start asking to get answers

Find the answer to your question by asking.

Ask question

Explore related questions

See similar questions with these tags.