I’ve this piece of code that registers a CSS in a baby theme and when visiting the front-end my_css
is definitely included. Why is that ? I believed that registering meant registering for later use
to permit – amongst different issues – conditional enqueuing of stylesheets/scripts. This should not be working with out enqueuing my_css
sooner or later, proper ?
operate register_my_styles()
{
wp_register_style('parent_theme', get_template_directory_uri() . '/fashion.css', '', null, 'all');
wp_register_style('my_css', get_stylesheet_directory_uri() . '/src/css/my_css', array('parent_theme'), null, 'all');
}
add_action('wp_loaded', 'register_my_styles');
Commenting out wp_register_style('my_css
not less than works :] however the way in which it behaves prevents me from utilizing conditional enqueuing since my_css
is rendered on the front-end by simply utilizing wp_register_style
.
Now the funky half is: I’m utilizing ParentTheme 4.10.4 as a dad or mum theme. After I downgrade for every model all the way in which to 4.0.1 then wp_register_style
works usually and does not output the CSS line on the frond-end.
Which might be fantastic however enqueuing additionally does not work:
operate register_my_styles()
{
wp_register_style('parent_theme', get_template_directory_uri() . '/fashion.css', '', null, 'all');
wp_register_style('my_css', get_stylesheet_directory_uri() . '/src/css/my_css', array('parent_theme'), null, 'all');
}
operate enqueue_my_styles()
{
wp_enqueue_style('parent_theme');
wp_enqueue_style('my_css');
}
add_action('wp_loaded', 'register_my_styles');
add_action('wp_enqueue_style', 'enqueue_my_styles');
What am I lacking and misunderstanding right here ?