Add style.css to functions.php in WordPress 7.0

WordPress never automatically queues style.css on the front end by default, even in a modern Full Site Editing (FSE) / Block theme.

While FSE themes rely heavily on theme.json for global styles, your theme’s main style.css file still needs to be explicitly enqueued if you want to use it for custom CSS rules, web fonts, or overrides.

Here is how you fix it. You need to hook a new function into wp_enqueue_scripts.

The Solution

Append this code to the bottom of your functions.php file:

functions.php

/**
 * Enqueue theme stylesheets with automatic cache busting.
 */
function themename_enqueue_styles() {
    // Get theme data from style.css
    $theme = wp_get_theme();
    $version = $theme->get( 'Version' );

    // Enqueue the main style.css file
    wp_enqueue_style( 
        'themename-style', 
        get_stylesheet_uri(), 
        array(), 
        $version // Dynamically pulls the version from your theme header to break cache
    );
}
add_action( 'wp_enqueue_scripts', 'themename_enqueue_styles' );

Why this is happening (The Quick Breakdown)

  • The Header Mystery: WordPress parses your style.css only to read the theme metadata (Theme Name, Author, Version) at the top of the file so it shows up in the Appearance dashboard. It doesn’t actually load the file’s code on the website for visitors.
  • The wp_enqueue_scripts Hook: This is the standard, safest way to tell WordPress, “Hey, load this CSS file when rendering the front end.”
  • get_stylesheet_uri(): This built-in WordPress function automatically targets the path to your theme’s primary style.css file, so you don’t have to hardcode URLs.

Add Custom Style to the Editor

functions.php

function add_theme_editor_styles() {
    // 1. Core opt-in support for block editor stylesheets
    add_theme_support( 'editor-styles' );

    // 2. Load the main style.css asset into the editor canvas iframe
    add_editor_style( 'style.css' );
}
add_action( 'after_setup_theme', 'add_theme_editor_styles' );

© 2026 All Rights Reserved.