Make WordPress Core

Opened 2 years ago

Closed 2 years ago

Last modified 2 years ago

#59997 closed defect (bug) (wontfix)

Twenty Twenty-Four Doesn't Enqueue Stylesheet

Reported by: script2see's profile script2see Owned by:
Milestone: Priority: normal
Severity: normal Version: 6.4
Component: Bundled Theme Keywords: close
Focuses: css Cc:

Description

Twenty Twenty-Four doesn't enqueue style.css, which doesn't appear in the header tags when you view source. So, there's no way to make style rules work in the main stylesheet of the theme.

Change History (7)

#1 @script2see
2 years ago

  • Focuses php-compatibility added

The following code is missing from functions.php:

function my_theme_enqueue_styles() {

wp_enqueue_style( 'my_theme_style', get_stylesheet_uri() );

}
add_action( 'wp_enqueue_scripts', 'my_theme_enqueue_styles' );

#2 follow-up: @poena
2 years ago

Hi
This is intentional because the theme is a block theme and does not use this file.

Instead, all custom CSS in the theme is loaded only when and where it is needed. As a bundled and default theme it is important that it uses the best and current practices.

-It is not recommended to make changes directly to theme files.
Instead you can use a child theme or the custom CSS features that are built into WordPress.

Last edited 2 years ago by poena (previous) (diff)

#3 @sabernhardt
2 years ago

  • Focuses php-compatibility removed
  • Keywords needs-patch removed
  • Milestone Awaiting Review deleted
  • Resolution set to wontfix
  • Status changed from new to closed

The temporary stylesheet was removed in
https://github.com/WordPress/twentytwentyfour/pull/458

Your support topic already links to the documentation article for including additional CSS within the Editor, and the video shows another method.

#4 in reply to: ↑ 2 @script2see
2 years ago

I understand the intent, but some types of blocks don't have all the needed functionality yet. So, custom CSS rules are needed as a supplement to the theme.

I've been customizing WordPress themes for many years, and I have always written style rules for style.css.

After examining the readme file for the Twenty Twenty-Four theme, I found nothing that would have indicated that the stylesheet hadn't been enqueued. Besides, I would need the plugin, Create Block Theme, to export a child theme version. That functionality has not yet been built into WordPress core.

I would certainly be willing to help flesh out the documentation for the theme and WordPress core. I wrote content for a custom software development company recently.

I don't think a lot of WordPress developers and users were aware that style.css is no longer enqueued.

Replying to poena:

Hi
This is intentional because the theme is a block theme and does not use this file.

Instead, all custom CSS in the theme is loaded only when and where it is needed. As a bundled and default theme it is important that it uses the best and current practices.

-It is not recommended to make changes directly to theme files.
Instead you can use a child theme or the custom CSS features that are built into WordPress.

#5 @onemaggie
2 years ago

Like Carolina said, these are best practices for block themes. And TT4 is not the first one to do so, TT3 does the same as well

#6 in reply to: ↑ description @davidtaubmann
2 years ago

  • Keywords close added

YES, "there's a (SIMPLE) way to make (CSS) style rules work in the main stylesheet of the theme." and this way will also be visible while using the full-site-editor.

The answer the girls gave is a bit misleading, since they never explained where are "the custom CSS features that are built into WordPress". Which lead me to hours lost searching for what they meant.
The section for CSS styles is located directly in "Twenty Twenty-Four" Theme Editor, just go:

  1. Appearance (themes);
  2. Editor (site-editor);
  3. Left Menu -> Styles (wp_global_styles);
  4. There's an Eye and a Pencil icons, click the pencil (edit);
  5. To the left, at the bottom you'll find "Additional CSS" or at the top inside the three dots button.

You can also go directly to "/wp-admin/site-editor.php?path=%2Fwp_global_styles&canvas=edit" and look for step 5.

Hope this helps many newbies with this template like me.

Replying to script2see:

Twenty Twenty-Four doesn't enqueue style.css, which doesn't appear in the header tags when you view source. So, there's no way to make style rules work in the main stylesheet of the theme.

#7 @priethor
2 years ago

Hi @davidtaubmann, thanks for joining WordPress.org and for sharing your feedback and thoughts on this ticket; welcome! 🎉

I would also like to remind you of the WordPress Code of Conduct and kindly ask you to avoid assuming other contributors’ gender and age based on handles and avatars and, more importantly, labeling and classifying community members and their interactions by any assumed gender or age. The participants in this ticket have a strong record of contributions to this project, and their input and interactions should be treated with the utmost respect, even if in disagreement. Calling them the girls diminishes them and their participation in this project, and it can feel patronizing or condescending.

Regarding your feedback and based on your comment, it is unclear what the misleading answers are; could you be more specific? What comments and parts would need clarifying? How can we make it more understandable in future interactions? If this is a recurring pain point, we should make it more obvious in onboarding and documentation material.

Note: See TracTickets for help on using tickets.