Why wp_head() function not loading style.css?

I am totally new to WordPress and developing my own theme but function.php is not loading CSS file.

header.php

<html>
<head>
<?php wp_head(); ?>
</head>
<body>
<h2>I’m header.php</h2>

single.php

<?php
get_header();
while (have_posts()) {
the_post();
?>
<h2><?php the_title(); ?></h2>
<?php the_content(); ?>

<?php }

?>

function.php

<?php
function main_css() {
wp_enqueue_style(‘style’, get_stylesheet_uri() );
}
add_action( ‘wp_enqueue_scripts’, ‘main_css’ );

style.css

/*
Theme Name: My Theme
Author: Tesla
Version: 1.0
*/
body{
color: green;
}
h1{
color: pink;
}

I have tried many ways but it’s not loading even disable the browser cookies, hard refresh, reinstall the WordPress.

Whats wrong with my code?

Read more here:: Why wp_head() function not loading style.css?

Leave a Reply

Your email address will not be published. Required fields are marked *