I'm a newbie to WordPress; I just started learning WordPress. I'm trying to link style.css in functions.php but I am unable to achieve what might be the issue here. Can anyone point me the right direction?
index.php
<?php
get_header();
?>
<?php
if ( have_posts() ) {
while ( have_posts() ) {
the_post();
echo 'Posts are foound';
}
} else {
echo 'No Posts are found';
}
?>
<div class="inner">
<?php bloginfo('title'); ?><br>
<?php bloginfo('description'); ?>
<?php echo "<h1>Hello world</h1>"; ?>
</div>
<?php
get_footer();
functions.php
function mortal_theme() {
wp_enqueue_style( 'style', get_template_directory_uri() . '/style.css' );
}
add_action( 'wp_enqueue_scripts', 'mortal_theme' );
style.css
h1 {
background-color: red;
color: yellow;
font-size: 28px;
font-weight: 700;
}
.inner {
width: 1100px;
margin: 0 auto;
}
header.php
<html>
<head>
<?php wp_head(); ?>
</head>
<header class="site-header">
<?php bloginfo('title'); ?>
</header>
footer.php
<footer>
<p><?php bloginfo('title');?> - © <?php echo date('Y');?></p>
</footer>
<?php wp_footer(); ?>
</body>
</html>
get_header()
. Your theme needs to have a header.php with the<head>
element in it, and the<?php wp_head(); ?>
function inside it.get_header()
call in there, it just didn't show up because the code wasn't formatted properly. I edited for code formatting (that doesn't answer whether there's a header.php or not, though).