I am trying to learn WP theme development. And at the moment I got some problems when I try to enqueue my stylesheet (id does'nt load). It is named style.css and located in my theme folder.

I have put this code in my functions.php file:

function my_theme_scripts() {
wp_register_style( 'style', get_stylesheet_uri() );
wp_enqueue_style( 'style', get_stylesheet_uri() );
add_action( 'wp_enqueue_scripts', 'my_theme_scripts' );

I can't understand what I am doing wrong? I have been reading the codex upside down. What am I doing wrong?

  • have you put this code in the fie functions.php ? --- add echo __FILE__; on the top of the file to be sure this file is called – mmm Aug 31 '15 at 22:07
  • I am not sure if I understand? Where should I put this code? In my functions? I already got tons of code in my functions for custom post types for example. And that is loading correctly. Earlier I was loading my CSS the wrong way (directly in the header) and that did work. When I now change to use enqueue it does'nt – Alex Aug 31 '15 at 22:19
  • do you have wp_head() in the head tag of your header.php file? – Milo Aug 31 '15 at 23:20
  • no, I dont! Will fix that! – Alex Aug 31 '15 at 23:28
  • Now it its working! Thanks alot, can't believe I forgot about the wp_head.. THANKS! – Alex Aug 31 '15 at 23:57

Please edit the path for the style sheet

And put the code in functions.php

function my_theme_scripts() {
wp_enqueue_style('style', get_stylesheet_directory_uri() . '/css/style.css',false,'all' );
add_action( 'wp_enqueue_scripts', 'my_theme_scripts' );
  • What if you remove the css from the path and just trywp_enqueue_style('style', get_stylesheet_directory_uri() . '/style.css',false,'all' ); within the enqueue hook – czerspalace Aug 31 '15 at 23:11
  • Ya you are right but he told that he has this file in css folder too – terminator Aug 31 '15 at 23:17

try define the css url.

for example this:

wp_register_style('style', get_template_directory_uri() . '/css/custom_css.css') );

  • Still same problem.. – Alex Aug 31 '15 at 22:04

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.