I am writing code in functions.php :

 function add_theme_styles() { wp_register_style('main', get_template_directory_uri() . '/css/main.css'); wp_enqueue_style('main'); } add_action('wp_enqueue_scripts', 'add_theme_styles'); 

Styles are not loaded. In header.php there is wp_head() . Tell me, please, what could be the problem?

  • What does the debugger show? Is there a piece of '/css/main.css' code or is it writing some kind of error in the debugger? - Basil Jimmy
  • I checked the method works. Check the path and the presence of the file itself. Also wp_head (). - Basil Jimmy

1 answer 1

I checked the method works. Check the path and the presence of the file itself. Also wp_head (). If you see that the file is physically there, but 404 is issued, then change the permalink to the standard in wordpress at the time of development and return it, after which it should work. This is a common problem when transferring and adding new files.

To start the url scanning mechanism you need to go here.

http://example.com/wp-admin/options-permalink.php

Links management menu in wordpress

Then swap the parameters and return the original, if necessary.

To overwrite the display rules by url, return to the default values, and then to those that you had before

After that, the lost pages and classes will be displayed at the address you assigned.

  • Thanks for the answer. I am new to this issue, I do not have a debugger ... And can I explain what it means to "change the permalink to the standard in wordpress"? Sorry for the stupid question. - Julia
  • I added to your answer, the code can be viewed on f12 using the console - Basil Jimmy
  • Thanks, earned! - Julia
  • Close the question then, you and I will then drop karma - Basil Jimmy