functions.php not adding css to website?
.everyoneloves__top-leaderboard:empty,.everyoneloves__mid-leaderboard:empty{ margin-bottom:0;
}
up vote
2
down vote
favorite
So I went through the forum to find a solution before I post a question, however I have yet to find it. I'm new to wordpress and I'm having a lot of fun learning on how to build my own website. However I am unable to add my css to my website this the code I have below.
functions.php
<?php
function fearnothing_script_enqueue(){
wp_enqueue_style("style", get_stylesheet_uri()."css/
fearnothing.css",false, 'all');
}
add_action('wp_enqueue_scripts', 'fearnothing_script_enqueue');
header.php
<!DOCTYPE html>
<html>
<head>
<title>lonely spaceship</title>
<?php wp_head(); ?>
</head>
<body>
footer.php
<footer>
<p></p>
</footer>
<?php wp_footer(); ?>
</body>
fearnothing.css
html, body {
margin: 0;
color: #91f213;
background-color:black;
font: sans-serif;
}
body{
padding: 20px;
}
h1{
color: yellow;
}
php css
add a comment |
up vote
2
down vote
favorite
So I went through the forum to find a solution before I post a question, however I have yet to find it. I'm new to wordpress and I'm having a lot of fun learning on how to build my own website. However I am unable to add my css to my website this the code I have below.
functions.php
<?php
function fearnothing_script_enqueue(){
wp_enqueue_style("style", get_stylesheet_uri()."css/
fearnothing.css",false, 'all');
}
add_action('wp_enqueue_scripts', 'fearnothing_script_enqueue');
header.php
<!DOCTYPE html>
<html>
<head>
<title>lonely spaceship</title>
<?php wp_head(); ?>
</head>
<body>
footer.php
<footer>
<p></p>
</footer>
<?php wp_footer(); ?>
</body>
fearnothing.css
html, body {
margin: 0;
color: #91f213;
background-color:black;
font: sans-serif;
}
body{
padding: 20px;
}
h1{
color: yellow;
}
php css
do you mean your CSS file is not added?
– André Kelling
Nov 21 at 8:35
Yeah, the css file is not adding to the website. I tried countless different ways to extract the dir of the css file.
– peter-cs
Nov 21 at 8:36
to be clear: you mention functions.php in your question headline, but inside your question you write function.php (hence the missing S). i recently ran into the same issue, so make sure, its called properly, to be loaded at all..
– honk31
Nov 21 at 9:00
ahh yes! it is called functions.php . will edit that now in the post!
– peter-cs
Nov 21 at 9:01
add a comment |
up vote
2
down vote
favorite
up vote
2
down vote
favorite
So I went through the forum to find a solution before I post a question, however I have yet to find it. I'm new to wordpress and I'm having a lot of fun learning on how to build my own website. However I am unable to add my css to my website this the code I have below.
functions.php
<?php
function fearnothing_script_enqueue(){
wp_enqueue_style("style", get_stylesheet_uri()."css/
fearnothing.css",false, 'all');
}
add_action('wp_enqueue_scripts', 'fearnothing_script_enqueue');
header.php
<!DOCTYPE html>
<html>
<head>
<title>lonely spaceship</title>
<?php wp_head(); ?>
</head>
<body>
footer.php
<footer>
<p></p>
</footer>
<?php wp_footer(); ?>
</body>
fearnothing.css
html, body {
margin: 0;
color: #91f213;
background-color:black;
font: sans-serif;
}
body{
padding: 20px;
}
h1{
color: yellow;
}
php css
So I went through the forum to find a solution before I post a question, however I have yet to find it. I'm new to wordpress and I'm having a lot of fun learning on how to build my own website. However I am unable to add my css to my website this the code I have below.
functions.php
<?php
function fearnothing_script_enqueue(){
wp_enqueue_style("style", get_stylesheet_uri()."css/
fearnothing.css",false, 'all');
}
add_action('wp_enqueue_scripts', 'fearnothing_script_enqueue');
header.php
<!DOCTYPE html>
<html>
<head>
<title>lonely spaceship</title>
<?php wp_head(); ?>
</head>
<body>
footer.php
<footer>
<p></p>
</footer>
<?php wp_footer(); ?>
</body>
fearnothing.css
html, body {
margin: 0;
color: #91f213;
background-color:black;
font: sans-serif;
}
body{
padding: 20px;
}
h1{
color: yellow;
}
php css
php css
edited Nov 21 at 9:02
asked Nov 21 at 8:33
peter-cs
155
155
do you mean your CSS file is not added?
– André Kelling
Nov 21 at 8:35
Yeah, the css file is not adding to the website. I tried countless different ways to extract the dir of the css file.
– peter-cs
Nov 21 at 8:36
to be clear: you mention functions.php in your question headline, but inside your question you write function.php (hence the missing S). i recently ran into the same issue, so make sure, its called properly, to be loaded at all..
– honk31
Nov 21 at 9:00
ahh yes! it is called functions.php . will edit that now in the post!
– peter-cs
Nov 21 at 9:01
add a comment |
do you mean your CSS file is not added?
– André Kelling
Nov 21 at 8:35
Yeah, the css file is not adding to the website. I tried countless different ways to extract the dir of the css file.
– peter-cs
Nov 21 at 8:36
to be clear: you mention functions.php in your question headline, but inside your question you write function.php (hence the missing S). i recently ran into the same issue, so make sure, its called properly, to be loaded at all..
– honk31
Nov 21 at 9:00
ahh yes! it is called functions.php . will edit that now in the post!
– peter-cs
Nov 21 at 9:01
do you mean your CSS file is not added?
– André Kelling
Nov 21 at 8:35
do you mean your CSS file is not added?
– André Kelling
Nov 21 at 8:35
Yeah, the css file is not adding to the website. I tried countless different ways to extract the dir of the css file.
– peter-cs
Nov 21 at 8:36
Yeah, the css file is not adding to the website. I tried countless different ways to extract the dir of the css file.
– peter-cs
Nov 21 at 8:36
to be clear: you mention functions.php in your question headline, but inside your question you write function.php (hence the missing S). i recently ran into the same issue, so make sure, its called properly, to be loaded at all..
– honk31
Nov 21 at 9:00
to be clear: you mention functions.php in your question headline, but inside your question you write function.php (hence the missing S). i recently ran into the same issue, so make sure, its called properly, to be loaded at all..
– honk31
Nov 21 at 9:00
ahh yes! it is called functions.php . will edit that now in the post!
– peter-cs
Nov 21 at 9:01
ahh yes! it is called functions.php . will edit that now in the post!
– peter-cs
Nov 21 at 9:01
add a comment |
2 Answers
2
active
oldest
votes
up vote
3
down vote
accepted
I don't know if you try to add a css file in your theme or plugin. I will provide both examples. Use wp_enqueue_style in combination with get_theme_file_uri to enqueu a stylesheet in your theme directory.
For a theme, see example
function add_styles() {
wp_enqueue_style( 'fontawesome-style', get_theme_file_uri( '/assets/css/all.css' ), array(), null );
}
add_action( 'wp_enqueue_scripts', 'add_styles' );
For a plugin, see example
function add_styles() {
wp_enqueue_style( 'example-styles-plugin', plugins_url('/assets/css/admin.css', __FILE__), array(), null );
}
add_action( 'wp_enqueue_scripts', 'add_styles' );
For both, add an external URL:
function add_styles() {
// Add Google Fonts
wp_enqueue_style('google_fonts', 'https://fonts.googleapis.com/css?family=Poppins:300,500,700', array(), null );
}
add_action( 'wp_enqueue_scripts', 'add_styles' );
add a comment |
up vote
1
down vote
I'm glad to know that you are having fun learning and building your own websites.
Here is the deal:
get_stylesheet_uri()
function returns the current theme stylesheet. It adds the style.css file from your current theme directory.
The solution:
If you want to enqueue any kind of assets file like CSS or JS on your theme, you have to use get_template_directory_uri() functions instead of get_stylesheet_uri().
Your code should be like this:
function fearnothing_script_enqueue(){
wp_enqueue_style("style", get_template_directory_uri()."/assets-file/css/fearnothing.css",false, 'all');
}
add_action('wp_enqueue_scripts', 'fearnothing_script_enqueue');
get_template_directory_uri()
function Retrieve theme directory URI.
For more information, you might take a look on codex documentation here
add a comment |
2 Answers
2
active
oldest
votes
2 Answers
2
active
oldest
votes
active
oldest
votes
active
oldest
votes
up vote
3
down vote
accepted
I don't know if you try to add a css file in your theme or plugin. I will provide both examples. Use wp_enqueue_style in combination with get_theme_file_uri to enqueu a stylesheet in your theme directory.
For a theme, see example
function add_styles() {
wp_enqueue_style( 'fontawesome-style', get_theme_file_uri( '/assets/css/all.css' ), array(), null );
}
add_action( 'wp_enqueue_scripts', 'add_styles' );
For a plugin, see example
function add_styles() {
wp_enqueue_style( 'example-styles-plugin', plugins_url('/assets/css/admin.css', __FILE__), array(), null );
}
add_action( 'wp_enqueue_scripts', 'add_styles' );
For both, add an external URL:
function add_styles() {
// Add Google Fonts
wp_enqueue_style('google_fonts', 'https://fonts.googleapis.com/css?family=Poppins:300,500,700', array(), null );
}
add_action( 'wp_enqueue_scripts', 'add_styles' );
add a comment |
up vote
3
down vote
accepted
I don't know if you try to add a css file in your theme or plugin. I will provide both examples. Use wp_enqueue_style in combination with get_theme_file_uri to enqueu a stylesheet in your theme directory.
For a theme, see example
function add_styles() {
wp_enqueue_style( 'fontawesome-style', get_theme_file_uri( '/assets/css/all.css' ), array(), null );
}
add_action( 'wp_enqueue_scripts', 'add_styles' );
For a plugin, see example
function add_styles() {
wp_enqueue_style( 'example-styles-plugin', plugins_url('/assets/css/admin.css', __FILE__), array(), null );
}
add_action( 'wp_enqueue_scripts', 'add_styles' );
For both, add an external URL:
function add_styles() {
// Add Google Fonts
wp_enqueue_style('google_fonts', 'https://fonts.googleapis.com/css?family=Poppins:300,500,700', array(), null );
}
add_action( 'wp_enqueue_scripts', 'add_styles' );
add a comment |
up vote
3
down vote
accepted
up vote
3
down vote
accepted
I don't know if you try to add a css file in your theme or plugin. I will provide both examples. Use wp_enqueue_style in combination with get_theme_file_uri to enqueu a stylesheet in your theme directory.
For a theme, see example
function add_styles() {
wp_enqueue_style( 'fontawesome-style', get_theme_file_uri( '/assets/css/all.css' ), array(), null );
}
add_action( 'wp_enqueue_scripts', 'add_styles' );
For a plugin, see example
function add_styles() {
wp_enqueue_style( 'example-styles-plugin', plugins_url('/assets/css/admin.css', __FILE__), array(), null );
}
add_action( 'wp_enqueue_scripts', 'add_styles' );
For both, add an external URL:
function add_styles() {
// Add Google Fonts
wp_enqueue_style('google_fonts', 'https://fonts.googleapis.com/css?family=Poppins:300,500,700', array(), null );
}
add_action( 'wp_enqueue_scripts', 'add_styles' );
I don't know if you try to add a css file in your theme or plugin. I will provide both examples. Use wp_enqueue_style in combination with get_theme_file_uri to enqueu a stylesheet in your theme directory.
For a theme, see example
function add_styles() {
wp_enqueue_style( 'fontawesome-style', get_theme_file_uri( '/assets/css/all.css' ), array(), null );
}
add_action( 'wp_enqueue_scripts', 'add_styles' );
For a plugin, see example
function add_styles() {
wp_enqueue_style( 'example-styles-plugin', plugins_url('/assets/css/admin.css', __FILE__), array(), null );
}
add_action( 'wp_enqueue_scripts', 'add_styles' );
For both, add an external URL:
function add_styles() {
// Add Google Fonts
wp_enqueue_style('google_fonts', 'https://fonts.googleapis.com/css?family=Poppins:300,500,700', array(), null );
}
add_action( 'wp_enqueue_scripts', 'add_styles' );
edited Nov 21 at 9:04
answered Nov 21 at 8:59
Remzi Cavdar
527213
527213
add a comment |
add a comment |
up vote
1
down vote
I'm glad to know that you are having fun learning and building your own websites.
Here is the deal:
get_stylesheet_uri()
function returns the current theme stylesheet. It adds the style.css file from your current theme directory.
The solution:
If you want to enqueue any kind of assets file like CSS or JS on your theme, you have to use get_template_directory_uri() functions instead of get_stylesheet_uri().
Your code should be like this:
function fearnothing_script_enqueue(){
wp_enqueue_style("style", get_template_directory_uri()."/assets-file/css/fearnothing.css",false, 'all');
}
add_action('wp_enqueue_scripts', 'fearnothing_script_enqueue');
get_template_directory_uri()
function Retrieve theme directory URI.
For more information, you might take a look on codex documentation here
add a comment |
up vote
1
down vote
I'm glad to know that you are having fun learning and building your own websites.
Here is the deal:
get_stylesheet_uri()
function returns the current theme stylesheet. It adds the style.css file from your current theme directory.
The solution:
If you want to enqueue any kind of assets file like CSS or JS on your theme, you have to use get_template_directory_uri() functions instead of get_stylesheet_uri().
Your code should be like this:
function fearnothing_script_enqueue(){
wp_enqueue_style("style", get_template_directory_uri()."/assets-file/css/fearnothing.css",false, 'all');
}
add_action('wp_enqueue_scripts', 'fearnothing_script_enqueue');
get_template_directory_uri()
function Retrieve theme directory URI.
For more information, you might take a look on codex documentation here
add a comment |
up vote
1
down vote
up vote
1
down vote
I'm glad to know that you are having fun learning and building your own websites.
Here is the deal:
get_stylesheet_uri()
function returns the current theme stylesheet. It adds the style.css file from your current theme directory.
The solution:
If you want to enqueue any kind of assets file like CSS or JS on your theme, you have to use get_template_directory_uri() functions instead of get_stylesheet_uri().
Your code should be like this:
function fearnothing_script_enqueue(){
wp_enqueue_style("style", get_template_directory_uri()."/assets-file/css/fearnothing.css",false, 'all');
}
add_action('wp_enqueue_scripts', 'fearnothing_script_enqueue');
get_template_directory_uri()
function Retrieve theme directory URI.
For more information, you might take a look on codex documentation here
I'm glad to know that you are having fun learning and building your own websites.
Here is the deal:
get_stylesheet_uri()
function returns the current theme stylesheet. It adds the style.css file from your current theme directory.
The solution:
If you want to enqueue any kind of assets file like CSS or JS on your theme, you have to use get_template_directory_uri() functions instead of get_stylesheet_uri().
Your code should be like this:
function fearnothing_script_enqueue(){
wp_enqueue_style("style", get_template_directory_uri()."/assets-file/css/fearnothing.css",false, 'all');
}
add_action('wp_enqueue_scripts', 'fearnothing_script_enqueue');
get_template_directory_uri()
function Retrieve theme directory URI.
For more information, you might take a look on codex documentation here
answered Nov 21 at 9:04
Mahfuz
645
645
add a comment |
add a comment |
Thanks for contributing an answer to WordPress Development Stack Exchange!
- Please be sure to answer the question. Provide details and share your research!
But avoid …
- Asking for help, clarification, or responding to other answers.
- Making statements based on opinion; back them up with references or personal experience.
To learn more, see our tips on writing great answers.
Some of your past answers have not been well-received, and you're in danger of being blocked from answering.
Please pay close attention to the following guidance:
- Please be sure to answer the question. Provide details and share your research!
But avoid …
- Asking for help, clarification, or responding to other answers.
- Making statements based on opinion; back them up with references or personal experience.
To learn more, see our tips on writing great answers.
Sign up or log in
StackExchange.ready(function () {
StackExchange.helpers.onClickDraftSave('#login-link');
});
Sign up using Google
Sign up using Facebook
Sign up using Email and Password
Post as a guest
Required, but never shown
StackExchange.ready(
function () {
StackExchange.openid.initPostLogin('.new-post-login', 'https%3a%2f%2fwordpress.stackexchange.com%2fquestions%2f319810%2ffunctions-php-not-adding-css-to-website%23new-answer', 'question_page');
}
);
Post as a guest
Required, but never shown
Sign up or log in
StackExchange.ready(function () {
StackExchange.helpers.onClickDraftSave('#login-link');
});
Sign up using Google
Sign up using Facebook
Sign up using Email and Password
Post as a guest
Required, but never shown
Sign up or log in
StackExchange.ready(function () {
StackExchange.helpers.onClickDraftSave('#login-link');
});
Sign up using Google
Sign up using Facebook
Sign up using Email and Password
Post as a guest
Required, but never shown
Sign up or log in
StackExchange.ready(function () {
StackExchange.helpers.onClickDraftSave('#login-link');
});
Sign up using Google
Sign up using Facebook
Sign up using Email and Password
Sign up using Google
Sign up using Facebook
Sign up using Email and Password
Post as a guest
Required, but never shown
Required, but never shown
Required, but never shown
Required, but never shown
Required, but never shown
Required, but never shown
Required, but never shown
Required, but never shown
Required, but never shown
do you mean your CSS file is not added?
– André Kelling
Nov 21 at 8:35
Yeah, the css file is not adding to the website. I tried countless different ways to extract the dir of the css file.
– peter-cs
Nov 21 at 8:36
to be clear: you mention functions.php in your question headline, but inside your question you write function.php (hence the missing S). i recently ran into the same issue, so make sure, its called properly, to be loaded at all..
– honk31
Nov 21 at 9:00
ahh yes! it is called functions.php . will edit that now in the post!
– peter-cs
Nov 21 at 9:01