Enqueuing Stylesheet of Child Theme

[ad_1]

Hi. I’m currently finishing up styling a child theme of Twenty Twenty-Four, and I’m not sure of the code that I should use to enqueue the child theme’s CSS stylsheet.

The child themes page of WordPress Developer Resources provides two versions of the code:

Version 1:

add_action( 'wp_enqueue_scripts', 'grand_sunrise_enqueue_styles' );

function grand_sunrise_enqueue_styles() {
	wp_enqueue_style( 
		'grand-sunrise-style', 
		get_stylesheet_uri()
	);
}

Version 2:

add_action( 'wp_enqueue_scripts', 'grand_sunrise_enqueue_styles' );

function grand_sunrise_enqueue_styles() {
	wp_enqueue_style( 
		'grand-sunrise-parent-style', 
		get_parent_theme_file_uri( 'style.css' )
	);
}

I was going to use the following code for my child theme, hlcbpc, but I’m not sure if it’s correct;

add_action( 'wp_enqueue_scripts', 'hlcpbc_styles' );

function hlcpbc_styles() {
	wp_enqueue_style( 
		'hlcpbc-style', 
		get_stylesheet_uri( 'style.css' )
	);
}

So, my child theme’s functions.php file would have the following:

<?php
/**
 * hlcpbc functions and definitions
 *
 * @link https://developer.projectdmc.org/themes/basics/theme-functions/
 *
 */

/**
 * Register block styles.
 */

add_action( 'wp_enqueue_scripts', 'hlcpbc_styles' );

function hlcpbc_styles() {
	wp_enqueue_style( 
		'hlcpbc-style', 
		get_stylesheet_uri( 'style.css' )
	);
}

Thanks in advance for your help.

  • This topic was modified 3 hours, 38 minutes ago by script2see.

 

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