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 the
functions.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?
WP_DEBUG
at wp-config.php totrue
? So it should be:define('WP_DEBUG', true);
. Do you see any error messages? – Bayu