• Resolved clueless00

    (@clueless00)


    Here is my code:

    home.php

    <div class="test-class">
        test text
    </div>

    functions.php

    <?php
    function blabla() {
    wp_enqueue_style( 'homepage', './homepage.css' );
    }
    add_action( 'wp_enqueue_scripts', 'blabla' );
    ?>

    homepage.css

    #test-class {
        color: red;
    }

    All the files are in the root folder of the theme.

    I don’t understand why the css is not enqueued. (The text in the div has no red color).

Viewing 3 replies - 1 through 3 (of 3 total)
  • Check your browser’s developer console (or view the page’s HTML source). You should be getting 404 for your homepage.css file.

    That’s because the CSS file’s location you provided is incorrect.

    Try:

    wp_enqueue_style( 'homepage', get_stylesheet_directory_uri() . '/homepage.css' );

    Thread Starter clueless00

    (@clueless00)

    Solved. Working after first try. Thank you.

    Thread Starter clueless00

    (@clueless00)

    Just to add this for clarification: I also had to add the following code to home.php, so that the css gets applied:

    <?php
    get_header(); ?>
Viewing 3 replies - 1 through 3 (of 3 total)
  • The topic ‘Enqueued css not applied.’ is closed to new replies.