• Hello. I am having real trouble with the new block-based development structure. In principle i agree with WordPress’s decision to implement theme development this way, but there are a few things lacking, which for a seasoned theme hacker from pre-block days are perplexing or entirely absent

    Essentially, i would like to use the block-based theme editor solely for theme development, but i come unstuck with the absence of custom css. There is no mention in the doc pages for Custom CSS that the custom css editor is MIA. There is no functions.php in the new block-based themes, so creating child themes is pure guesswork

    Does anyone have answers to basic questions such as how to enqueue styles and scripts and is there any recent documentation on advanced styling for the new block-based themes?

    Many thanks in advance

    The page I need help with: [log in to see the link]

Viewing 5 replies - 1 through 5 (of 5 total)
  • Moderator bcworkz

    (@bcworkz)

    Block themes may still utilize functions.php to execute certain PHP code on start up. You can enqueue style and script files this way, but in block themes you are expected to utilize theme.json styling or register custom block styles.

    Thread Starter djcuppat

    (@djcuppat)

    Many thanks for the tips. I have looked at the info relating to making your own block theme and how to register/deregister custom block styles (as pointed out), but i don’t have any idea of the structure and content of the child or how it interacts with the parent. Non-block themes have a clear page addressing these details and what’s really lacking is one for block-based children. I assume there are similarities, but i don’t want to make assumptions and i don’t have endless hours for trial and error!

    Previously, building child themes made sense because the parents were usually maintained, so you could focus on styling and function without worrying about compatibility, security, etc.

    Now, i’m not clear whether children are relevant for block themes because it seems the theme core is embedded within the wordpress distribution and the files that constitute block themes are merely a collection of extensions and mods to that core. If that’s the case, then creating bespoke block themes makes more sense and is functionally equivalent to child theming for non-block themes

    So the question is, is it better to make a duplicate of a block theme and edit the dupe or is a child of a maintained block-based parent the preferred / sensible / most flexible option?

    many thanks in advance, i apologise for my verbosity

    Moderator bcworkz

    (@bcworkz)

    The child theme concept is still valid. If you were to duplicate a theme and modify it, either your modifications will be lost when the theme updates, or if you disable updates, you will miss out on possibly critical security updates.

    Unfortunately, because block themes are relatively new, there is not detailed documentation like we have for classic themes. There are a number of nuances that are different. You would not be alone in struggling with child block themes. One of many examples. In particular note in the linked topic is Kathryn P.’s reply and suggestion of using create-block-theme plugin to get started.

    Thread Starter djcuppat

    (@djcuppat)

    Many thanks for your help and words of wisdom. I confess i am having trouble searching this forum too, or i would have found that essential post myself!

    BTW: I “cheated” and used a plugin to inject the needed CSS mods

    Moderator bcworkz

    (@bcworkz)

    That’s not cheating, that’s working efficiently 🙂

    As you have likely noticed, the Additional CSS customizer section where we like to place CSS mods under classic themes is no longer there with block themes. In fact it actually is still there, but it’s hidden by default. It can be re-exposed by adding any callback to the “customize_register” action, even if the callback does nothing.

    Using a plugin instead is fine, I’m just pointing out another option.

Viewing 5 replies - 1 through 5 (of 5 total)
  • The topic ‘Custom CSS and Theme Children’ is closed to new replies.