How to link style.css in functions.php

To get this working:

(1) Your index.php file should begin with:

<?php get_header(); ?>

and end with:

<?php get_footer(); ?>

(2) Your header.php file should have the following right before the closing </head> tag:

<?php wp_head(); ?>

Note: header.php also has other things, but I am assuming you have them set up already.

(3) Your footer.php file should have the following right before the closing </body> tag:

<?php wp_footer(); ?> 

(4) In your functions.php, modify your the second line of your wp_enqueue_style so that it looks like this:

wp_enqueue_style( 'style', get_stylesheet_uri() );

The whole function in the end should look like this:

function mortal_theme() {
    wp_enqueue_style( 'style', get_template_directory_uri() );
  }
add_action( 'wp_enqueue_scripts', 'mortal_theme' );

This is because the style.css in your theme folder is the main stylesheet for the theme – so you don’t need to tell WordPress to look for style.css, it will know what to look for.

Update:

I have recreated your theme using your code on a local WordPress installation to test it, and here is a screenshot of what I see when I visit the page:

enter image description here

The theme folder has the following files:

  1. style.css
  2. index.php
  3. header.php
  4. functions.php
  5. footer.php

And I copied and pasted the exact code for each file from your original question, with one exception: for functions.php I added the starting <?php tag so my final code looks like this:

<?php
   function mortal_theme() {
      wp_enqueue_style( 'style', get_template_directory_uri() . '/style.css);
   }
   add_action( 'wp_enqueue_scripts', 'mortal_theme' );

Based on the screenshot above, everything seems to be working correctly.

However, if I remove the <?php that I added (to make my code match the one in your question 100%), this is what I see when I view the page:

enter image description here

What do you see when you view your page? If you’re getting results like that in the second screenshot, then it is because you do not have the starting <?php in the beginning of your functions.php file. Add that and you’re good to go, insha’Allah.