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
New contributor
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
New contributor
do you mean your CSS file is not added?
– André Kelling
22 hours ago
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
22 hours ago
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
21 hours ago
ahh yes! it is called functions.php . will edit that now in the post!
– peter-cs
21 hours ago
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
New contributor
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
New contributor
New contributor
edited 21 hours ago
New contributor
asked 22 hours ago
peter-cs
134
134
New contributor
New contributor
do you mean your CSS file is not added?
– André Kelling
22 hours ago
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
22 hours ago
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
21 hours ago
ahh yes! it is called functions.php . will edit that now in the post!
– peter-cs
21 hours ago
add a comment |
do you mean your CSS file is not added?
– André Kelling
22 hours ago
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
22 hours ago
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
21 hours ago
ahh yes! it is called functions.php . will edit that now in the post!
– peter-cs
21 hours ago
do you mean your CSS file is not added?
– André Kelling
22 hours ago
do you mean your CSS file is not added?
– André Kelling
22 hours ago
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
22 hours ago
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
22 hours ago
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
21 hours ago
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
21 hours ago
ahh yes! it is called functions.php . will edit that now in the post!
– peter-cs
21 hours ago
ahh yes! it is called functions.php . will edit that now in the post!
– peter-cs
21 hours ago
add a comment |
2 Answers
2
active
oldest
votes
up vote
2
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
2
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
2
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
2
down vote
accepted
up vote
2
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 21 hours ago
answered 21 hours ago
Remzi Cavdar
329110
329110
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 21 hours ago
Mahfuz
645
645
add a comment |
add a comment |
peter-cs is a new contributor. Be nice, and check out our Code of Conduct.
peter-cs is a new contributor. Be nice, and check out our Code of Conduct.
peter-cs is a new contributor. Be nice, and check out our Code of Conduct.
peter-cs is a new contributor. Be nice, and check out our Code of Conduct.
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
22 hours ago
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
22 hours ago
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
21 hours ago
ahh yes! it is called functions.php . will edit that now in the post!
– peter-cs
21 hours ago