I created my first child theme from WP 2022 using a plugin (create theme)
This worked, but only up to a point.
First question to ask yourself is – do you really need a child theme?
Possibly not… if you’re 100% happy with the functions and styling that TT2 can offer – which are without doubt extensive and highly flexible in their own right.
Personally, I came up against a fairly antagonistic styling limitation quite soon into my first steps with TT2 – the infamous “left-justify” limitation <link to article>. This required some modification, albeit small, to the theme.json file. Reason 1 for having a child theme.
So, for those who find themselves in a similar boat to me, I’m going to break down the manual steps to create your own child theme, that actually works.
By the end of this process, you will have a fully functioning child theme that inherits styling from the parent style.css and theme.json, BUT you will have your own style.css and theme.json that you can customize, as well as a template folder where you can create your own templates that over-ride the parent templates.
- create folder and sub-folders
- create style.css
- create theme.json (give example of margin, true)
- create functions.php (mention https://developer.wordpress.org/themes/advanced-topics/child-themes/#:~:text=The%20recommended%20way%20of%20enqueuing,in%20your%20child%20theme’s%20functions. NOT WORKING – i probably missed some vital syntax or got something else wrong since the guide assumes you know what you’re doing [which I don’t – after-all, I am a self-confessed blockhead!]. Was lucky enough to come across this post however on the TT2 support forum: https://wordpress.org/support/topic/twenty-twenty-two-ignores-child-theme-css/ — many thanks to moushik who made things very simple, no need to even specify the child theme, a simple & elegant solution!)
- create zip of child theme folder
- upload and install via wp
You can now edit your style.css and theme.json in whatever way you see fit. Personally, I like to edit with VS code for its myriad of features. <<article on VS code for css & json theme files>>.
Of course you can still add custom CSS via customize.php which does have the benefit of live changes, but has the significant (in my opinion) downside of a very narrow text editing field which soon starts to get restrictive. I prefer to keep a separate chrome incognito window open with the live site, which I refresh via CTRL+R and can use chrome dev tools via F12 when necessary.
Leave a Reply