• Resolved marcin1333

    (@marcin1333)


    I started using the Twenty Twenty-Three theme with the idea of creating a child theme. While working, I noticed that the Twenty Twenty-Three theme does not have a functions.php file. Why and where did it go, can I safely add it to the Twenty Twenty-Three theme child?

Viewing 11 replies - 1 through 11 (of 11 total)
  • Moderator Kathryn Presner

    (@zoonini)

    Hi @marcin1333 – Twenty Twenty-Three is a special type of theme called a “block theme,” which means that it gives you access to Site Editing. Check out the resources here to give you a better understanding of how this theme works:

    https://wordpress.org/support/topic/support-resources-for-twenty-twenty-three/

    Making a child theme of a block theme is a bit different than making a child of a classic (non-block) theme. I’d suggest you give the Create Block Theme plugin a try to make your child theme, as it makes things simpler than doing it manually. Once you create your block theme using the plugin, you can deactivate/uninstall it.

    Let me know how it goes!

    Thread Starter marcin1333

    (@marcin1333)

    Thank you for your quick reply, you are very helpful. I understand how a block theme works and I’ve used Tweny Twenty-Two successfully by creating a child theme for it and using the functions.php file. I don’t use classic old themes. To clarify my question: in Tweny Twenty Twenty-Three theme can I add functions.php file and use it like in Twenty Twenty-Two theme?

    @marcin1333

    I created a functions.php file and uploaded it to the theme directory without a problem. I have not yet created a TT3 child theme but, if one is shipped with TT3 in future, I have a backup of my code that I can upload (or maybe I iwll get around to creating a child theme).

    Me too, I added a functions.php that enqueues “by the book” (So both, the childthemes style.css as well as the parents one (which is empty) and it works.
    Without the functions.php my style.css (that was created by Create Block Theme) was ignored.
    I guess, it has to work, or people can’t at all switch to tt-t without loosing their style.
    But me too, I find it a bit disturbing to not find one in the parent theme… That leaves me with a big QUESTION:

    Does that mean the php-tag of my functions.php should be closed??? lol, sorry for the ignorance.

    Moderator Kathryn Presner

    (@zoonini)

    Hi, everyone!

    Let me clarify a couple of things:

    The Create Block Theme plugin is not designed to add CSS to a site, since block themes are meant to be designed with Styles and the Site Editor, rather than external CSS.

    That said, there’s nothing wrong with manually enqueuing a stylesheet via a functions.php file, as you would for any other theme.

    If you only want custom CSS (and not other types of changes such as HTML, or theme.json) you don’t need a child theme at all, though. Instead, add wp-admin/customize.php after your URL to access the Additional CSS panel via the Customizer.

    Does that mean the php-tag of my functions.php should be closed???

    As a best practice it’s my understanding that you should never add ?> at the end of functions.php as it can cause a fatal error under certain circumstances.

    • This reply was modified 1 year, 5 months ago by Kathryn Presner. Reason: fixed typo in code

    As a best practice it’s my understanding that you should never add ?> at the end of functions.php as it can cause a fatal error under certain circumstances.

    To expand on this a bit: It’s best practice to avoid adding a closing ?> tag at the end of any PHP file.

    Technically, there’s nothing invalid about it if it is the very last thing in the file. However, what often happens is that there is leftover whitespace after the closing tag (new line, empty space, etc.), which will cause a fatal error. So, it’s best to just avoid the potential issue altogether.

    Thank you both very much, for the clarification and explications!
    I don’t even know anymore why I had the idea to close the tag… The more I learn about defining settings and styles json-files the less I will have to rely on custom css. Still, I am very happy to be able to work with the style.css in the meantime.
    I am super happy with the block themes and the freedom that comes with them :)))

    Moderator Kathryn Presner

    (@zoonini)

    @progresstination You’re welcome… and I’m very glad to hear you’re enjoying exploring block themes!

    I wondered about the closing php tag also @progresstination. Thank you Justin T. @greenshady for clarifying.

    Kathryn @zoonini thank you for your help with adding CSS with this:

    If you only want custom CSS (and not other types of changes such as HTML, or theme.json) you don’t need a child theme at all, though. Instead, add wp-admin/customize.php after your URL to access the Additional CSS panel via the Customizer.

    (Full) Site editing is so much easier than The Before Times.

    Moderator Kathryn Presner

    (@zoonini)

    @vlbooth

    (Full) Site editing is so much easier than The Before Times.

    That’s wonderful to hear! I agree, it makes so many things, so much simpler. 🙂

    Moderator Kathryn Presner

    (@zoonini)

    I’m marking this as resolved since it’s been a while since the last reply. If folks need help with anything else, don’t hesitate to start a new thread.

Viewing 11 replies - 1 through 11 (of 11 total)
  • The topic ‘where is the functions.php file?’ is closed to new replies.