Wordpress file functions.php is not loading the style.css
I can't seem to get the functions.php file of my WordPress theme load my stylesheet.
The files I've created in the theme directory of my WordPress theme are as follow with their respective contents;
style.css
/*
Theme Name: Theme Study
Author: A
Version: 1.0.0
*/
body {
color: #4d5a6c !important;
}
header.php
<!DOCTYPE html>
<html lang="en">
<head>
<?php wp_head(); ?>
</head>
<body>
<h2>This is the header</h2>
index.php
<?php get_header();
while ( have_posts() ) {
the_post(); ?>
<h2><a href="<?php the_permalink(); ?>"><?php the_title(); ?></a></h2>
<?php the_content();
}
get_footer(); ?>
footer.php
<h4>This is the footer</h4>
<?php wp_footer(); ?>
</body>
</html>
functions.php
<?php
function style_files() {
wp_enqueue_style( 'style_main', get_stylesheet_uri() );
}
add_action( 'wp_enqueue_scripts', 'style_files' );
On the other hand, I've realised that when I reference directly the stylesheet inside the header.phpfile as below, it works as expected, but my aim is to achieve that in thefunctions.php` file of my WordPress theme.
<!DOCTYPE html>
<html lang="en">
<head>
<link rel="stylesheet" type="text/css" href="<?php echo get_stylesheet_uri(); ?>" />
<?php wp_head(); ?>
</head>
<body>
<h2>This is the header</h2>
Why my style.ccs not getting loaded from the functions.php file?
css wordpress wordpress-theming
|
show 5 more comments
I can't seem to get the functions.php file of my WordPress theme load my stylesheet.
The files I've created in the theme directory of my WordPress theme are as follow with their respective contents;
style.css
/*
Theme Name: Theme Study
Author: A
Version: 1.0.0
*/
body {
color: #4d5a6c !important;
}
header.php
<!DOCTYPE html>
<html lang="en">
<head>
<?php wp_head(); ?>
</head>
<body>
<h2>This is the header</h2>
index.php
<?php get_header();
while ( have_posts() ) {
the_post(); ?>
<h2><a href="<?php the_permalink(); ?>"><?php the_title(); ?></a></h2>
<?php the_content();
}
get_footer(); ?>
footer.php
<h4>This is the footer</h4>
<?php wp_footer(); ?>
</body>
</html>
functions.php
<?php
function style_files() {
wp_enqueue_style( 'style_main', get_stylesheet_uri() );
}
add_action( 'wp_enqueue_scripts', 'style_files' );
On the other hand, I've realised that when I reference directly the stylesheet inside the header.phpfile as below, it works as expected, but my aim is to achieve that in thefunctions.php` file of my WordPress theme.
<!DOCTYPE html>
<html lang="en">
<head>
<link rel="stylesheet" type="text/css" href="<?php echo get_stylesheet_uri(); ?>" />
<?php wp_head(); ?>
</head>
<body>
<h2>This is the header</h2>
Why my style.ccs not getting loaded from the functions.php file?
css wordpress wordpress-theming
I have tried with above code and its working fine. I am getting style.css file
– Jogi Mehul
Dec 31 '18 at 12:42
Is there a way to see or debug what is wrong?
– Alê Moraes
Dec 31 '18 at 12:54
make sure your style.css reside on theme root folder and request you to provide your page view source so will get better idea.
– Jogi Mehul
Dec 31 '18 at 13:01
I put the source code
– Alê Moraes
Dec 31 '18 at 13:33
What if you try to setWP_DEBUGat wp-config.php totrue? So it should be:define('WP_DEBUG', true);. Do you see any error messages?
– Bayu
Dec 31 '18 at 13:38
|
show 5 more comments
I can't seem to get the functions.php file of my WordPress theme load my stylesheet.
The files I've created in the theme directory of my WordPress theme are as follow with their respective contents;
style.css
/*
Theme Name: Theme Study
Author: A
Version: 1.0.0
*/
body {
color: #4d5a6c !important;
}
header.php
<!DOCTYPE html>
<html lang="en">
<head>
<?php wp_head(); ?>
</head>
<body>
<h2>This is the header</h2>
index.php
<?php get_header();
while ( have_posts() ) {
the_post(); ?>
<h2><a href="<?php the_permalink(); ?>"><?php the_title(); ?></a></h2>
<?php the_content();
}
get_footer(); ?>
footer.php
<h4>This is the footer</h4>
<?php wp_footer(); ?>
</body>
</html>
functions.php
<?php
function style_files() {
wp_enqueue_style( 'style_main', get_stylesheet_uri() );
}
add_action( 'wp_enqueue_scripts', 'style_files' );
On the other hand, I've realised that when I reference directly the stylesheet inside the header.phpfile as below, it works as expected, but my aim is to achieve that in thefunctions.php` file of my WordPress theme.
<!DOCTYPE html>
<html lang="en">
<head>
<link rel="stylesheet" type="text/css" href="<?php echo get_stylesheet_uri(); ?>" />
<?php wp_head(); ?>
</head>
<body>
<h2>This is the header</h2>
Why my style.ccs not getting loaded from the functions.php file?
css wordpress wordpress-theming
I can't seem to get the functions.php file of my WordPress theme load my stylesheet.
The files I've created in the theme directory of my WordPress theme are as follow with their respective contents;
style.css
/*
Theme Name: Theme Study
Author: A
Version: 1.0.0
*/
body {
color: #4d5a6c !important;
}
header.php
<!DOCTYPE html>
<html lang="en">
<head>
<?php wp_head(); ?>
</head>
<body>
<h2>This is the header</h2>
index.php
<?php get_header();
while ( have_posts() ) {
the_post(); ?>
<h2><a href="<?php the_permalink(); ?>"><?php the_title(); ?></a></h2>
<?php the_content();
}
get_footer(); ?>
footer.php
<h4>This is the footer</h4>
<?php wp_footer(); ?>
</body>
</html>
functions.php
<?php
function style_files() {
wp_enqueue_style( 'style_main', get_stylesheet_uri() );
}
add_action( 'wp_enqueue_scripts', 'style_files' );
On the other hand, I've realised that when I reference directly the stylesheet inside the header.phpfile as below, it works as expected, but my aim is to achieve that in thefunctions.php` file of my WordPress theme.
<!DOCTYPE html>
<html lang="en">
<head>
<link rel="stylesheet" type="text/css" href="<?php echo get_stylesheet_uri(); ?>" />
<?php wp_head(); ?>
</head>
<body>
<h2>This is the header</h2>
Why my style.ccs not getting loaded from the functions.php file?
css wordpress wordpress-theming
css wordpress wordpress-theming
edited Dec 31 '18 at 15:16
nyedidikeke
2,74442033
2,74442033
asked Dec 31 '18 at 12:34
Alê MoraesAlê Moraes
1356
1356
I have tried with above code and its working fine. I am getting style.css file
– Jogi Mehul
Dec 31 '18 at 12:42
Is there a way to see or debug what is wrong?
– Alê Moraes
Dec 31 '18 at 12:54
make sure your style.css reside on theme root folder and request you to provide your page view source so will get better idea.
– Jogi Mehul
Dec 31 '18 at 13:01
I put the source code
– Alê Moraes
Dec 31 '18 at 13:33
What if you try to setWP_DEBUGat wp-config.php totrue? So it should be:define('WP_DEBUG', true);. Do you see any error messages?
– Bayu
Dec 31 '18 at 13:38
|
show 5 more comments
I have tried with above code and its working fine. I am getting style.css file
– Jogi Mehul
Dec 31 '18 at 12:42
Is there a way to see or debug what is wrong?
– Alê Moraes
Dec 31 '18 at 12:54
make sure your style.css reside on theme root folder and request you to provide your page view source so will get better idea.
– Jogi Mehul
Dec 31 '18 at 13:01
I put the source code
– Alê Moraes
Dec 31 '18 at 13:33
What if you try to setWP_DEBUGat wp-config.php totrue? So it should be:define('WP_DEBUG', true);. Do you see any error messages?
– Bayu
Dec 31 '18 at 13:38
I have tried with above code and its working fine. I am getting style.css file
– Jogi Mehul
Dec 31 '18 at 12:42
I have tried with above code and its working fine. I am getting style.css file
– Jogi Mehul
Dec 31 '18 at 12:42
Is there a way to see or debug what is wrong?
– Alê Moraes
Dec 31 '18 at 12:54
Is there a way to see or debug what is wrong?
– Alê Moraes
Dec 31 '18 at 12:54
make sure your style.css reside on theme root folder and request you to provide your page view source so will get better idea.
– Jogi Mehul
Dec 31 '18 at 13:01
make sure your style.css reside on theme root folder and request you to provide your page view source so will get better idea.
– Jogi Mehul
Dec 31 '18 at 13:01
I put the source code
– Alê Moraes
Dec 31 '18 at 13:33
I put the source code
– Alê Moraes
Dec 31 '18 at 13:33
What if you try to set
WP_DEBUG at wp-config.php to true? So it should be: define('WP_DEBUG', true);. Do you see any error messages?– Bayu
Dec 31 '18 at 13:38
What if you try to set
WP_DEBUG at wp-config.php to true? So it should be: define('WP_DEBUG', true);. Do you see any error messages?– Bayu
Dec 31 '18 at 13:38
|
show 5 more comments
4 Answers
4
active
oldest
votes
Use this code I think its work fine for you.
function theme_styles(){
// Load all of the styles that need to appear on all pages
wp_enqueue_style( 'main', get_template_directory_uri() . '/style.css' );
wp_enqueue_style( 'custom', get_template_directory_uri() . '/css/custom.css' );
}
add_action('wp_enqueue_scripts', 'theme_styles');
Still not loading
– Alê Moraes
Dec 31 '18 at 12:53
Check your css path. i am already using this its work fine for me
– Harsh Khare
Dec 31 '18 at 12:54
If I put this tag " <link rel="stylesheet" type="text/css" href="<?php echo get_stylesheet_uri(); ?>" />" in the head, than it will work, but i learned that the correct way is to insert wp_head and make wp_enqueue_style in the functions.php
– Alê Moraes
Dec 31 '18 at 14:24
add a comment |
What if you try to put this at your function.php file:
<?php
function style_files(){
wp_enqueue_style( 'parent-style', get_template_directory_uri() . '/style.css' );
wp_enqueue_style( 'child-style', get_stylesheet_directory_uri() . '/style.css');
}
add_action('wp_enqueue_scripts', 'style_files');
The one with style id named: parent-style usually is for parent theme ( if you are developing child theme or just single theme ), 2nd one is if you are developing child theme and should load style.css at your child theme.
I'm making a theme from zero, all my files are in the root of the theme folder
– Alê Moraes
Dec 31 '18 at 13:58
So you just need the one with "parent-style" in my snippet. You can just name it with "main-style" or anything else you like. Have you tried that? And you should ensure that your style name is unique ( no duplication of style id )
– Bayu
Dec 31 '18 at 14:01
It´s a fresh study, I don´t have any files, just those above, i change the line "parent-style", but it doesn't work, it seem the wp_head is not working
– Alê Moraes
Dec 31 '18 at 14:16
That is kind of weird. Maybe you should try to callwp_enqueue_scripttoo to ensure ifwp_headdoesn't work.
– Bayu
Dec 31 '18 at 14:31
add a comment |
Use get_template_directory_uri() instead of get_stylesheet_uri() as in your functions.php file.
Below, a snippet illustrating how it should read;
function style_files() {
wp_enqueue_style(
'style_main',
get_template_directory_uri() . '/style.css',
array(),
false,
'all'
);
}
add_action( 'wp_enqueue_scripts', 'style_files' );
It is a safe way to add/enqueue a stylesheet file to your WordPress theme.
The above follows this format:
wp_enqueue_style( $handle, $src, $deps, $ver, $media );
where
$handle
(string) (Required) Name of the stylesheet. Should be unique.
$src
(string) (Optional) Full URL of the stylesheet,
or path of the stylesheet relative to the WordPress root directory.
Default value: ''
$deps
(array) (Optional) An array of registered stylesheet handles this stylesheet depends on.
Default value: array()
$ver
(string|bool|null) (Optional) String specifying stylesheet version number, if it has one,
which is added to the URL as a query string for cache busting purposes. If version is set to
false, a version number is automatically added equal to current installed WordPress version.
If set to null, no version is added.
Default value: false
$media
(string) (Optional) The media for which this stylesheet has been defined.
Accepts media types like 'all', 'print' and 'screen', or media queries like
'(orientation: portrait)' and '(max-width: 640px)'.
Default value: 'all'
More information available here.
If I put <link rel="stylesheet" type="text/css" href="<?php echo get_stylesheet_uri(); ?>" /> in the head it will work, it seem the wp_head();doens´t work
– Alê Moraes
Dec 31 '18 at 13:59
You don't need to do that once you did in yourfunctions.phpfile. It should work. You may want to add a solid background colour (eg:body{color: #4d5a6c !important;background-color:red;}) to checking closer loading of thestyle.cssfile of your theme. Head over to the WordPress codex site for more detail.
– nyedidikeke
Dec 31 '18 at 14:50
@AlêMoraes: kindly feedback after troubleshooting with a solid background colour. Also, my comment above assumes you have the folder containing your custom WordPress theme inside thewp-content/themesdirectory of your WordPress installation withindex.php,style.css,functions.php,footer.php, andheader.phpas files.
– nyedidikeke
Dec 31 '18 at 14:56
add a comment |
please replace this function with your wp_enqueue_style function.
wp_enqueue_style( 'style', get_stylesheet_uri() );
Still not loading
– Alê Moraes
Dec 31 '18 at 12:53
can you show me the url of your website?
– rAnA bilAl
Dec 31 '18 at 12:54
I am on localhost
– Alê Moraes
Dec 31 '18 at 12:55
check the link in inspect element mode in browser.
– rAnA bilAl
Dec 31 '18 at 12:56
If I put this tag " <link rel="stylesheet" type="text/css" href="<?php echo get_stylesheet_uri(); ?>" />" in the head, than it will work, but i learned that the correct way is to insert wp_head and make wp_enqueue_style in the functions.php
– Alê Moraes
Dec 31 '18 at 14:22
add a comment |
Your Answer
StackExchange.ifUsing("editor", function () {
StackExchange.using("externalEditor", function () {
StackExchange.using("snippets", function () {
StackExchange.snippets.init();
});
});
}, "code-snippets");
StackExchange.ready(function() {
var channelOptions = {
tags: "".split(" "),
id: "1"
};
initTagRenderer("".split(" "), "".split(" "), channelOptions);
StackExchange.using("externalEditor", function() {
// Have to fire editor after snippets, if snippets enabled
if (StackExchange.settings.snippets.snippetsEnabled) {
StackExchange.using("snippets", function() {
createEditor();
});
}
else {
createEditor();
}
});
function createEditor() {
StackExchange.prepareEditor({
heartbeatType: 'answer',
autoActivateHeartbeat: false,
convertImagesToLinks: true,
noModals: true,
showLowRepImageUploadWarning: true,
reputationToPostImages: 10,
bindNavPrevention: true,
postfix: "",
imageUploader: {
brandingHtml: "Powered by u003ca class="icon-imgur-white" href="https://imgur.com/"u003eu003c/au003e",
contentPolicyHtml: "User contributions licensed under u003ca href="https://creativecommons.org/licenses/by-sa/3.0/"u003ecc by-sa 3.0 with attribution requiredu003c/au003e u003ca href="https://stackoverflow.com/legal/content-policy"u003e(content policy)u003c/au003e",
allowUrls: true
},
onDemand: true,
discardSelector: ".discard-answer"
,immediatelyShowMarkdownHelp:true
});
}
});
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%2fstackoverflow.com%2fquestions%2f53987589%2fwordpress-file-functions-php-is-not-loading-the-style-css%23new-answer', 'question_page');
}
);
Post as a guest
Required, but never shown
4 Answers
4
active
oldest
votes
4 Answers
4
active
oldest
votes
active
oldest
votes
active
oldest
votes
Use this code I think its work fine for you.
function theme_styles(){
// Load all of the styles that need to appear on all pages
wp_enqueue_style( 'main', get_template_directory_uri() . '/style.css' );
wp_enqueue_style( 'custom', get_template_directory_uri() . '/css/custom.css' );
}
add_action('wp_enqueue_scripts', 'theme_styles');
Still not loading
– Alê Moraes
Dec 31 '18 at 12:53
Check your css path. i am already using this its work fine for me
– Harsh Khare
Dec 31 '18 at 12:54
If I put this tag " <link rel="stylesheet" type="text/css" href="<?php echo get_stylesheet_uri(); ?>" />" in the head, than it will work, but i learned that the correct way is to insert wp_head and make wp_enqueue_style in the functions.php
– Alê Moraes
Dec 31 '18 at 14:24
add a comment |
Use this code I think its work fine for you.
function theme_styles(){
// Load all of the styles that need to appear on all pages
wp_enqueue_style( 'main', get_template_directory_uri() . '/style.css' );
wp_enqueue_style( 'custom', get_template_directory_uri() . '/css/custom.css' );
}
add_action('wp_enqueue_scripts', 'theme_styles');
Still not loading
– Alê Moraes
Dec 31 '18 at 12:53
Check your css path. i am already using this its work fine for me
– Harsh Khare
Dec 31 '18 at 12:54
If I put this tag " <link rel="stylesheet" type="text/css" href="<?php echo get_stylesheet_uri(); ?>" />" in the head, than it will work, but i learned that the correct way is to insert wp_head and make wp_enqueue_style in the functions.php
– Alê Moraes
Dec 31 '18 at 14:24
add a comment |
Use this code I think its work fine for you.
function theme_styles(){
// Load all of the styles that need to appear on all pages
wp_enqueue_style( 'main', get_template_directory_uri() . '/style.css' );
wp_enqueue_style( 'custom', get_template_directory_uri() . '/css/custom.css' );
}
add_action('wp_enqueue_scripts', 'theme_styles');
Use this code I think its work fine for you.
function theme_styles(){
// Load all of the styles that need to appear on all pages
wp_enqueue_style( 'main', get_template_directory_uri() . '/style.css' );
wp_enqueue_style( 'custom', get_template_directory_uri() . '/css/custom.css' );
}
add_action('wp_enqueue_scripts', 'theme_styles');
answered Dec 31 '18 at 12:51
Harsh KhareHarsh Khare
4309
4309
Still not loading
– Alê Moraes
Dec 31 '18 at 12:53
Check your css path. i am already using this its work fine for me
– Harsh Khare
Dec 31 '18 at 12:54
If I put this tag " <link rel="stylesheet" type="text/css" href="<?php echo get_stylesheet_uri(); ?>" />" in the head, than it will work, but i learned that the correct way is to insert wp_head and make wp_enqueue_style in the functions.php
– Alê Moraes
Dec 31 '18 at 14:24
add a comment |
Still not loading
– Alê Moraes
Dec 31 '18 at 12:53
Check your css path. i am already using this its work fine for me
– Harsh Khare
Dec 31 '18 at 12:54
If I put this tag " <link rel="stylesheet" type="text/css" href="<?php echo get_stylesheet_uri(); ?>" />" in the head, than it will work, but i learned that the correct way is to insert wp_head and make wp_enqueue_style in the functions.php
– Alê Moraes
Dec 31 '18 at 14:24
Still not loading
– Alê Moraes
Dec 31 '18 at 12:53
Still not loading
– Alê Moraes
Dec 31 '18 at 12:53
Check your css path. i am already using this its work fine for me
– Harsh Khare
Dec 31 '18 at 12:54
Check your css path. i am already using this its work fine for me
– Harsh Khare
Dec 31 '18 at 12:54
If I put this tag " <link rel="stylesheet" type="text/css" href="<?php echo get_stylesheet_uri(); ?>" />" in the head, than it will work, but i learned that the correct way is to insert wp_head and make wp_enqueue_style in the functions.php
– Alê Moraes
Dec 31 '18 at 14:24
If I put this tag " <link rel="stylesheet" type="text/css" href="<?php echo get_stylesheet_uri(); ?>" />" in the head, than it will work, but i learned that the correct way is to insert wp_head and make wp_enqueue_style in the functions.php
– Alê Moraes
Dec 31 '18 at 14:24
add a comment |
What if you try to put this at your function.php file:
<?php
function style_files(){
wp_enqueue_style( 'parent-style', get_template_directory_uri() . '/style.css' );
wp_enqueue_style( 'child-style', get_stylesheet_directory_uri() . '/style.css');
}
add_action('wp_enqueue_scripts', 'style_files');
The one with style id named: parent-style usually is for parent theme ( if you are developing child theme or just single theme ), 2nd one is if you are developing child theme and should load style.css at your child theme.
I'm making a theme from zero, all my files are in the root of the theme folder
– Alê Moraes
Dec 31 '18 at 13:58
So you just need the one with "parent-style" in my snippet. You can just name it with "main-style" or anything else you like. Have you tried that? And you should ensure that your style name is unique ( no duplication of style id )
– Bayu
Dec 31 '18 at 14:01
It´s a fresh study, I don´t have any files, just those above, i change the line "parent-style", but it doesn't work, it seem the wp_head is not working
– Alê Moraes
Dec 31 '18 at 14:16
That is kind of weird. Maybe you should try to callwp_enqueue_scripttoo to ensure ifwp_headdoesn't work.
– Bayu
Dec 31 '18 at 14:31
add a comment |
What if you try to put this at your function.php file:
<?php
function style_files(){
wp_enqueue_style( 'parent-style', get_template_directory_uri() . '/style.css' );
wp_enqueue_style( 'child-style', get_stylesheet_directory_uri() . '/style.css');
}
add_action('wp_enqueue_scripts', 'style_files');
The one with style id named: parent-style usually is for parent theme ( if you are developing child theme or just single theme ), 2nd one is if you are developing child theme and should load style.css at your child theme.
I'm making a theme from zero, all my files are in the root of the theme folder
– Alê Moraes
Dec 31 '18 at 13:58
So you just need the one with "parent-style" in my snippet. You can just name it with "main-style" or anything else you like. Have you tried that? And you should ensure that your style name is unique ( no duplication of style id )
– Bayu
Dec 31 '18 at 14:01
It´s a fresh study, I don´t have any files, just those above, i change the line "parent-style", but it doesn't work, it seem the wp_head is not working
– Alê Moraes
Dec 31 '18 at 14:16
That is kind of weird. Maybe you should try to callwp_enqueue_scripttoo to ensure ifwp_headdoesn't work.
– Bayu
Dec 31 '18 at 14:31
add a comment |
What if you try to put this at your function.php file:
<?php
function style_files(){
wp_enqueue_style( 'parent-style', get_template_directory_uri() . '/style.css' );
wp_enqueue_style( 'child-style', get_stylesheet_directory_uri() . '/style.css');
}
add_action('wp_enqueue_scripts', 'style_files');
The one with style id named: parent-style usually is for parent theme ( if you are developing child theme or just single theme ), 2nd one is if you are developing child theme and should load style.css at your child theme.
What if you try to put this at your function.php file:
<?php
function style_files(){
wp_enqueue_style( 'parent-style', get_template_directory_uri() . '/style.css' );
wp_enqueue_style( 'child-style', get_stylesheet_directory_uri() . '/style.css');
}
add_action('wp_enqueue_scripts', 'style_files');
The one with style id named: parent-style usually is for parent theme ( if you are developing child theme or just single theme ), 2nd one is if you are developing child theme and should load style.css at your child theme.
answered Dec 31 '18 at 13:47
BayuBayu
538512
538512
I'm making a theme from zero, all my files are in the root of the theme folder
– Alê Moraes
Dec 31 '18 at 13:58
So you just need the one with "parent-style" in my snippet. You can just name it with "main-style" or anything else you like. Have you tried that? And you should ensure that your style name is unique ( no duplication of style id )
– Bayu
Dec 31 '18 at 14:01
It´s a fresh study, I don´t have any files, just those above, i change the line "parent-style", but it doesn't work, it seem the wp_head is not working
– Alê Moraes
Dec 31 '18 at 14:16
That is kind of weird. Maybe you should try to callwp_enqueue_scripttoo to ensure ifwp_headdoesn't work.
– Bayu
Dec 31 '18 at 14:31
add a comment |
I'm making a theme from zero, all my files are in the root of the theme folder
– Alê Moraes
Dec 31 '18 at 13:58
So you just need the one with "parent-style" in my snippet. You can just name it with "main-style" or anything else you like. Have you tried that? And you should ensure that your style name is unique ( no duplication of style id )
– Bayu
Dec 31 '18 at 14:01
It´s a fresh study, I don´t have any files, just those above, i change the line "parent-style", but it doesn't work, it seem the wp_head is not working
– Alê Moraes
Dec 31 '18 at 14:16
That is kind of weird. Maybe you should try to callwp_enqueue_scripttoo to ensure ifwp_headdoesn't work.
– Bayu
Dec 31 '18 at 14:31
I'm making a theme from zero, all my files are in the root of the theme folder
– Alê Moraes
Dec 31 '18 at 13:58
I'm making a theme from zero, all my files are in the root of the theme folder
– Alê Moraes
Dec 31 '18 at 13:58
So you just need the one with "parent-style" in my snippet. You can just name it with "main-style" or anything else you like. Have you tried that? And you should ensure that your style name is unique ( no duplication of style id )
– Bayu
Dec 31 '18 at 14:01
So you just need the one with "parent-style" in my snippet. You can just name it with "main-style" or anything else you like. Have you tried that? And you should ensure that your style name is unique ( no duplication of style id )
– Bayu
Dec 31 '18 at 14:01
It´s a fresh study, I don´t have any files, just those above, i change the line "parent-style", but it doesn't work, it seem the wp_head is not working
– Alê Moraes
Dec 31 '18 at 14:16
It´s a fresh study, I don´t have any files, just those above, i change the line "parent-style", but it doesn't work, it seem the wp_head is not working
– Alê Moraes
Dec 31 '18 at 14:16
That is kind of weird. Maybe you should try to call
wp_enqueue_script too to ensure if wp_head doesn't work.– Bayu
Dec 31 '18 at 14:31
That is kind of weird. Maybe you should try to call
wp_enqueue_script too to ensure if wp_head doesn't work.– Bayu
Dec 31 '18 at 14:31
add a comment |
Use get_template_directory_uri() instead of get_stylesheet_uri() as in your functions.php file.
Below, a snippet illustrating how it should read;
function style_files() {
wp_enqueue_style(
'style_main',
get_template_directory_uri() . '/style.css',
array(),
false,
'all'
);
}
add_action( 'wp_enqueue_scripts', 'style_files' );
It is a safe way to add/enqueue a stylesheet file to your WordPress theme.
The above follows this format:
wp_enqueue_style( $handle, $src, $deps, $ver, $media );
where
$handle
(string) (Required) Name of the stylesheet. Should be unique.
$src
(string) (Optional) Full URL of the stylesheet,
or path of the stylesheet relative to the WordPress root directory.
Default value: ''
$deps
(array) (Optional) An array of registered stylesheet handles this stylesheet depends on.
Default value: array()
$ver
(string|bool|null) (Optional) String specifying stylesheet version number, if it has one,
which is added to the URL as a query string for cache busting purposes. If version is set to
false, a version number is automatically added equal to current installed WordPress version.
If set to null, no version is added.
Default value: false
$media
(string) (Optional) The media for which this stylesheet has been defined.
Accepts media types like 'all', 'print' and 'screen', or media queries like
'(orientation: portrait)' and '(max-width: 640px)'.
Default value: 'all'
More information available here.
If I put <link rel="stylesheet" type="text/css" href="<?php echo get_stylesheet_uri(); ?>" /> in the head it will work, it seem the wp_head();doens´t work
– Alê Moraes
Dec 31 '18 at 13:59
You don't need to do that once you did in yourfunctions.phpfile. It should work. You may want to add a solid background colour (eg:body{color: #4d5a6c !important;background-color:red;}) to checking closer loading of thestyle.cssfile of your theme. Head over to the WordPress codex site for more detail.
– nyedidikeke
Dec 31 '18 at 14:50
@AlêMoraes: kindly feedback after troubleshooting with a solid background colour. Also, my comment above assumes you have the folder containing your custom WordPress theme inside thewp-content/themesdirectory of your WordPress installation withindex.php,style.css,functions.php,footer.php, andheader.phpas files.
– nyedidikeke
Dec 31 '18 at 14:56
add a comment |
Use get_template_directory_uri() instead of get_stylesheet_uri() as in your functions.php file.
Below, a snippet illustrating how it should read;
function style_files() {
wp_enqueue_style(
'style_main',
get_template_directory_uri() . '/style.css',
array(),
false,
'all'
);
}
add_action( 'wp_enqueue_scripts', 'style_files' );
It is a safe way to add/enqueue a stylesheet file to your WordPress theme.
The above follows this format:
wp_enqueue_style( $handle, $src, $deps, $ver, $media );
where
$handle
(string) (Required) Name of the stylesheet. Should be unique.
$src
(string) (Optional) Full URL of the stylesheet,
or path of the stylesheet relative to the WordPress root directory.
Default value: ''
$deps
(array) (Optional) An array of registered stylesheet handles this stylesheet depends on.
Default value: array()
$ver
(string|bool|null) (Optional) String specifying stylesheet version number, if it has one,
which is added to the URL as a query string for cache busting purposes. If version is set to
false, a version number is automatically added equal to current installed WordPress version.
If set to null, no version is added.
Default value: false
$media
(string) (Optional) The media for which this stylesheet has been defined.
Accepts media types like 'all', 'print' and 'screen', or media queries like
'(orientation: portrait)' and '(max-width: 640px)'.
Default value: 'all'
More information available here.
If I put <link rel="stylesheet" type="text/css" href="<?php echo get_stylesheet_uri(); ?>" /> in the head it will work, it seem the wp_head();doens´t work
– Alê Moraes
Dec 31 '18 at 13:59
You don't need to do that once you did in yourfunctions.phpfile. It should work. You may want to add a solid background colour (eg:body{color: #4d5a6c !important;background-color:red;}) to checking closer loading of thestyle.cssfile of your theme. Head over to the WordPress codex site for more detail.
– nyedidikeke
Dec 31 '18 at 14:50
@AlêMoraes: kindly feedback after troubleshooting with a solid background colour. Also, my comment above assumes you have the folder containing your custom WordPress theme inside thewp-content/themesdirectory of your WordPress installation withindex.php,style.css,functions.php,footer.php, andheader.phpas files.
– nyedidikeke
Dec 31 '18 at 14:56
add a comment |
Use get_template_directory_uri() instead of get_stylesheet_uri() as in your functions.php file.
Below, a snippet illustrating how it should read;
function style_files() {
wp_enqueue_style(
'style_main',
get_template_directory_uri() . '/style.css',
array(),
false,
'all'
);
}
add_action( 'wp_enqueue_scripts', 'style_files' );
It is a safe way to add/enqueue a stylesheet file to your WordPress theme.
The above follows this format:
wp_enqueue_style( $handle, $src, $deps, $ver, $media );
where
$handle
(string) (Required) Name of the stylesheet. Should be unique.
$src
(string) (Optional) Full URL of the stylesheet,
or path of the stylesheet relative to the WordPress root directory.
Default value: ''
$deps
(array) (Optional) An array of registered stylesheet handles this stylesheet depends on.
Default value: array()
$ver
(string|bool|null) (Optional) String specifying stylesheet version number, if it has one,
which is added to the URL as a query string for cache busting purposes. If version is set to
false, a version number is automatically added equal to current installed WordPress version.
If set to null, no version is added.
Default value: false
$media
(string) (Optional) The media for which this stylesheet has been defined.
Accepts media types like 'all', 'print' and 'screen', or media queries like
'(orientation: portrait)' and '(max-width: 640px)'.
Default value: 'all'
More information available here.
Use get_template_directory_uri() instead of get_stylesheet_uri() as in your functions.php file.
Below, a snippet illustrating how it should read;
function style_files() {
wp_enqueue_style(
'style_main',
get_template_directory_uri() . '/style.css',
array(),
false,
'all'
);
}
add_action( 'wp_enqueue_scripts', 'style_files' );
It is a safe way to add/enqueue a stylesheet file to your WordPress theme.
The above follows this format:
wp_enqueue_style( $handle, $src, $deps, $ver, $media );
where
$handle
(string) (Required) Name of the stylesheet. Should be unique.
$src
(string) (Optional) Full URL of the stylesheet,
or path of the stylesheet relative to the WordPress root directory.
Default value: ''
$deps
(array) (Optional) An array of registered stylesheet handles this stylesheet depends on.
Default value: array()
$ver
(string|bool|null) (Optional) String specifying stylesheet version number, if it has one,
which is added to the URL as a query string for cache busting purposes. If version is set to
false, a version number is automatically added equal to current installed WordPress version.
If set to null, no version is added.
Default value: false
$media
(string) (Optional) The media for which this stylesheet has been defined.
Accepts media types like 'all', 'print' and 'screen', or media queries like
'(orientation: portrait)' and '(max-width: 640px)'.
Default value: 'all'
More information available here.
edited Dec 31 '18 at 14:00
answered Dec 31 '18 at 13:44
nyedidikekenyedidikeke
2,74442033
2,74442033
If I put <link rel="stylesheet" type="text/css" href="<?php echo get_stylesheet_uri(); ?>" /> in the head it will work, it seem the wp_head();doens´t work
– Alê Moraes
Dec 31 '18 at 13:59
You don't need to do that once you did in yourfunctions.phpfile. It should work. You may want to add a solid background colour (eg:body{color: #4d5a6c !important;background-color:red;}) to checking closer loading of thestyle.cssfile of your theme. Head over to the WordPress codex site for more detail.
– nyedidikeke
Dec 31 '18 at 14:50
@AlêMoraes: kindly feedback after troubleshooting with a solid background colour. Also, my comment above assumes you have the folder containing your custom WordPress theme inside thewp-content/themesdirectory of your WordPress installation withindex.php,style.css,functions.php,footer.php, andheader.phpas files.
– nyedidikeke
Dec 31 '18 at 14:56
add a comment |
If I put <link rel="stylesheet" type="text/css" href="<?php echo get_stylesheet_uri(); ?>" /> in the head it will work, it seem the wp_head();doens´t work
– Alê Moraes
Dec 31 '18 at 13:59
You don't need to do that once you did in yourfunctions.phpfile. It should work. You may want to add a solid background colour (eg:body{color: #4d5a6c !important;background-color:red;}) to checking closer loading of thestyle.cssfile of your theme. Head over to the WordPress codex site for more detail.
– nyedidikeke
Dec 31 '18 at 14:50
@AlêMoraes: kindly feedback after troubleshooting with a solid background colour. Also, my comment above assumes you have the folder containing your custom WordPress theme inside thewp-content/themesdirectory of your WordPress installation withindex.php,style.css,functions.php,footer.php, andheader.phpas files.
– nyedidikeke
Dec 31 '18 at 14:56
If I put <link rel="stylesheet" type="text/css" href="<?php echo get_stylesheet_uri(); ?>" /> in the head it will work, it seem the wp_head();doens´t work
– Alê Moraes
Dec 31 '18 at 13:59
If I put <link rel="stylesheet" type="text/css" href="<?php echo get_stylesheet_uri(); ?>" /> in the head it will work, it seem the wp_head();doens´t work
– Alê Moraes
Dec 31 '18 at 13:59
You don't need to do that once you did in your
functions.php file. It should work. You may want to add a solid background colour (eg: body{color: #4d5a6c !important;background-color:red;}) to checking closer loading of the style.css file of your theme. Head over to the WordPress codex site for more detail.– nyedidikeke
Dec 31 '18 at 14:50
You don't need to do that once you did in your
functions.php file. It should work. You may want to add a solid background colour (eg: body{color: #4d5a6c !important;background-color:red;}) to checking closer loading of the style.css file of your theme. Head over to the WordPress codex site for more detail.– nyedidikeke
Dec 31 '18 at 14:50
@AlêMoraes: kindly feedback after troubleshooting with a solid background colour. Also, my comment above assumes you have the folder containing your custom WordPress theme inside the
wp-content/themes directory of your WordPress installation with index.php, style.css, functions.php, footer.php, and header.php as files.– nyedidikeke
Dec 31 '18 at 14:56
@AlêMoraes: kindly feedback after troubleshooting with a solid background colour. Also, my comment above assumes you have the folder containing your custom WordPress theme inside the
wp-content/themes directory of your WordPress installation with index.php, style.css, functions.php, footer.php, and header.php as files.– nyedidikeke
Dec 31 '18 at 14:56
add a comment |
please replace this function with your wp_enqueue_style function.
wp_enqueue_style( 'style', get_stylesheet_uri() );
Still not loading
– Alê Moraes
Dec 31 '18 at 12:53
can you show me the url of your website?
– rAnA bilAl
Dec 31 '18 at 12:54
I am on localhost
– Alê Moraes
Dec 31 '18 at 12:55
check the link in inspect element mode in browser.
– rAnA bilAl
Dec 31 '18 at 12:56
If I put this tag " <link rel="stylesheet" type="text/css" href="<?php echo get_stylesheet_uri(); ?>" />" in the head, than it will work, but i learned that the correct way is to insert wp_head and make wp_enqueue_style in the functions.php
– Alê Moraes
Dec 31 '18 at 14:22
add a comment |
please replace this function with your wp_enqueue_style function.
wp_enqueue_style( 'style', get_stylesheet_uri() );
Still not loading
– Alê Moraes
Dec 31 '18 at 12:53
can you show me the url of your website?
– rAnA bilAl
Dec 31 '18 at 12:54
I am on localhost
– Alê Moraes
Dec 31 '18 at 12:55
check the link in inspect element mode in browser.
– rAnA bilAl
Dec 31 '18 at 12:56
If I put this tag " <link rel="stylesheet" type="text/css" href="<?php echo get_stylesheet_uri(); ?>" />" in the head, than it will work, but i learned that the correct way is to insert wp_head and make wp_enqueue_style in the functions.php
– Alê Moraes
Dec 31 '18 at 14:22
add a comment |
please replace this function with your wp_enqueue_style function.
wp_enqueue_style( 'style', get_stylesheet_uri() );
please replace this function with your wp_enqueue_style function.
wp_enqueue_style( 'style', get_stylesheet_uri() );
edited Dec 31 '18 at 14:53
Harsh Khare
4309
4309
answered Dec 31 '18 at 12:47
rAnA bilAlrAnA bilAl
264
264
Still not loading
– Alê Moraes
Dec 31 '18 at 12:53
can you show me the url of your website?
– rAnA bilAl
Dec 31 '18 at 12:54
I am on localhost
– Alê Moraes
Dec 31 '18 at 12:55
check the link in inspect element mode in browser.
– rAnA bilAl
Dec 31 '18 at 12:56
If I put this tag " <link rel="stylesheet" type="text/css" href="<?php echo get_stylesheet_uri(); ?>" />" in the head, than it will work, but i learned that the correct way is to insert wp_head and make wp_enqueue_style in the functions.php
– Alê Moraes
Dec 31 '18 at 14:22
add a comment |
Still not loading
– Alê Moraes
Dec 31 '18 at 12:53
can you show me the url of your website?
– rAnA bilAl
Dec 31 '18 at 12:54
I am on localhost
– Alê Moraes
Dec 31 '18 at 12:55
check the link in inspect element mode in browser.
– rAnA bilAl
Dec 31 '18 at 12:56
If I put this tag " <link rel="stylesheet" type="text/css" href="<?php echo get_stylesheet_uri(); ?>" />" in the head, than it will work, but i learned that the correct way is to insert wp_head and make wp_enqueue_style in the functions.php
– Alê Moraes
Dec 31 '18 at 14:22
Still not loading
– Alê Moraes
Dec 31 '18 at 12:53
Still not loading
– Alê Moraes
Dec 31 '18 at 12:53
can you show me the url of your website?
– rAnA bilAl
Dec 31 '18 at 12:54
can you show me the url of your website?
– rAnA bilAl
Dec 31 '18 at 12:54
I am on localhost
– Alê Moraes
Dec 31 '18 at 12:55
I am on localhost
– Alê Moraes
Dec 31 '18 at 12:55
check the link in inspect element mode in browser.
– rAnA bilAl
Dec 31 '18 at 12:56
check the link in inspect element mode in browser.
– rAnA bilAl
Dec 31 '18 at 12:56
If I put this tag " <link rel="stylesheet" type="text/css" href="<?php echo get_stylesheet_uri(); ?>" />" in the head, than it will work, but i learned that the correct way is to insert wp_head and make wp_enqueue_style in the functions.php
– Alê Moraes
Dec 31 '18 at 14:22
If I put this tag " <link rel="stylesheet" type="text/css" href="<?php echo get_stylesheet_uri(); ?>" />" in the head, than it will work, but i learned that the correct way is to insert wp_head and make wp_enqueue_style in the functions.php
– Alê Moraes
Dec 31 '18 at 14:22
add a comment |
Thanks for contributing an answer to Stack Overflow!
- 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%2fstackoverflow.com%2fquestions%2f53987589%2fwordpress-file-functions-php-is-not-loading-the-style-css%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
I have tried with above code and its working fine. I am getting style.css file
– Jogi Mehul
Dec 31 '18 at 12:42
Is there a way to see or debug what is wrong?
– Alê Moraes
Dec 31 '18 at 12:54
make sure your style.css reside on theme root folder and request you to provide your page view source so will get better idea.
– Jogi Mehul
Dec 31 '18 at 13:01
I put the source code
– Alê Moraes
Dec 31 '18 at 13:33
What if you try to set
WP_DEBUGat wp-config.php totrue? So it should be:define('WP_DEBUG', true);. Do you see any error messages?– Bayu
Dec 31 '18 at 13:38