Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

In generated child theme the style.css of the parent isn't loaded. #289

Closed
seindal opened this issue Mar 27, 2023 · 1 comment
Closed

In generated child theme the style.css of the parent isn't loaded. #289

seindal opened this issue Mar 27, 2023 · 1 comment

Comments

@seindal
Copy link

seindal commented Mar 27, 2023

A child theme created with the plugin might not work as intended, ad the parent's style.css isn't loaded automatically.

In my case, to get it to work, I had to create a functions.php file in the new theme, with these lines:

`<?php

add_action( 'wp_enqueue_scripts', function () {
$parenthandle = 'parent-style';
$theme = wp_get_theme();
wp_enqueue_style( $parenthandle,
get_template_directory_uri() . '/style.css',
array(), // If the parent theme code has a dependency, copy it to here.
$theme->parent()->get( 'Version' )
);
} );
`

Also, the id of the child's style.css in the generated HTML contains the name of the parent theme, not the child theme.

@matiasbenedetto
Copy link
Contributor

Hi @seindal 👋 , thanks for your report!

parent's style.css isn't loaded automatically

I could not reproduce this issue.
What I did:

  • Activated Disco theme.
  • Created a child theme
  • Activated child theme created

Result: Disco (parent theme) styles.css file is loading fine in the child theme.

Please note that Disco enqueues its own style.css file using functions.php. If the theme you are using as the parent theme is not enqueuing their own style.css file, it won't load on the child theme either. For example, Twenty Twenty-Three doesn't load any theme CSS file. This is how WordPress works and it's not specifically related to the plugin.

The id of the child's style.css in the generated HTML contains the name of the parent theme, not the child theme.

This issue was already fixed here and released as part of the 1.8.1 version of the plugin. Related to the answer above: If your parent theme was enqueuing the style.css file this name collision between parent and child could be causing the problem. Please update the plugin version and try again.

I'm closing this issue but feel free to re-open it if your problem persists!

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

No branches or pull requests

2 participants