The first thing to point out here is that get_template_directory()
returns an absolute path instead of a URL.
Instead you will need to make use of either get_template_directory_uri()
or get_stylesheet_directory_uri()
.
Your example would then look like this:
<link rel="stylesheet" type="text/css" href="<?php echo get_template_directory_uri(); ?>/css/style.css">
The second thing to address is how you are adding your stylesheet. Wordpress has a very useful function that is optimised for adding stylesheets called: wp_enqueue_style()
.
Instead of manually adding your stylesheet to the header.php
inside your theme directory, you can instead add it inside your functions.php
file, like this:
add_action( 'wp_enqueue_scripts', 'so_my_custom_scripts' );
function so_my_custom_scripts() {
wp_enqueue_style( 'my-custom-stylesheet', get_template_directory_uri() . '/css/style.css', array(), '20180618' );
}