css file not loading in wordpress

[ad_1]

Hello I am simply trying to create a wordpress theme from scratch . I created a functions.php and I want to link my css file to index.php.

​

<?php
function theme_files()
{
wp_enqueue_style( ‘mytheme-style’, get_theme_file_uri(‘/build/buildstyle.css’) );
}

add_action(‘wp_enqueue_scripts’, ‘theme_files’);

?>

This function runs when i test it with a echo. But the css file doesn’t apply to the index.php. What am I missing to get my css file to run on index.php without having to link it in the head?

[ad_2]
2 Comments
  1. On a separate line before you do the enqueue, copy your get_theme_file_uri() function call and echo it to ensure that it’s doing what it should be doing. Test that it returns a valid url.

  2. The path is incorrect if this is the main css – try:

    `wp_enqueue_style(‘mycss’, get_stylesheet_uri() );`

    If not, try it without the /

    `wp_enqueue_style( ‘mytheme-style’, get_theme_file_uri( ‘build/buildstyle.css’ ) );`

 

This site will teach you how to build a WordPress website for beginners. We will cover everything from installing WordPress to adding pages, posts, and images to your site. You will learn how to customize your site with themes and plugins, as well as how to market your site online.

Buy WordPress Transfer