0

I can't in any way include css in my theme using functions.php

I tried to include css using the link tag, but it only loads it on the first page, then when I go to open other pages (for example the example page) I don't load any style, how can I do it?

this is the code:

function theme_styles()
{
    wp_enqueue_style( 'style', get_template_directory_uri() . '/style.css' );
  wp_enqueue_style( 'bootstrap', get_template_directory_uri() . '/css/bootstrap.min.css' );
  wp_enqueue_style( 'font', get_template_directory_uri() . '/css/font-awesome.min.css' );
}
add_action('wp_enqueue_scripts', 'theme_styles');
  • Does the tag not appear on the other pages? Which file is this code located in? Are there any errors or warnings in your browser dev tools console? Is this a child theme? – Tom J Nowell Jan 9 at 17:53
  • 2
    Is this a child theme? If so, you probably want to use get_stylesheet_directory_uri() to point to child theme stylesheets. get_template_directory_uri() pulls from the parent theme. – WebElaine Jan 9 at 17:55
  • Does your theme have a header.php file with the wp_head() function inside the <head> tags? – Jacob Peattie Jan 10 at 0:04
0

In your first enqueue type get_stylesheet_directory_uri() instead of get_template_directory_uri For stylesheet its functions.php requires get_stylesheet_directory_uri()

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service, privacy policy and cookie policy

Not the answer you're looking for? Browse other questions tagged or ask your own question.