Ahmad Awais

NAVIGATE


SHARE


Introducing _Child – A WordPress Child Theme Boilerplate

Ahmad AwaisAhmad Awais

“I found out there was no child theme included. Dang! Now I have to create one!”

— #my_reaction_when

This is how we all sound when we have to create a child theme. There is really no rocket science to the process of creating child themes, but as a front-end fanatic, I always look for the best practices.

Today when I had to create a child theme, I thought of creating a boilerplate first, by DRY (Don’t Repeat Yourself) philosophy. So, there you go, a WordPress child theme boilerplate was born, and the only parent (me) chose to call it _child.

_child_WP-child-boilerplate-theme-ahmad-awais

How to Stuff?#

There are only two files in _child. Which are

Style.css#

Inside _child’s style.css, there is nothing but a comment for WP to read it as a theme. At line #7 there is a template tag, which you need to replace with the folder’s name of your parent theme.

Functions.php#

This file is a bit interesting. There’s a function called aa_enqueue_styles() which is responsible for enqueuing two style sheets.

If you have any questions, let me know.

_Child WP Child Theme Boilerplate#

It lives at GitHub under a tree called GPL license. Start it, fork it. Pull requests are welcomed!

Download v1.0.0Star or Fork

P.S. _child is an open-source theme, which means anyone can send pull requests to enhance it and make it better. My friend Matt Cromwell recently contributed to _child in the form of a branch called cleanup, _child in this branch dequeues and deregisters parent theme’s sidebars, widgets, post_types, and scripts (JS & CSS). Thus the name is cleanup.

P.P.S. A few beginner developers requested this gif on how to clone the _child boilerplate.

Clone_child

 

Founder & CEO at Langbase.com · Ex VP DevRel Rapid · Google Developers Advisory Board (gDAB) founding member. 🧑‍💻 AI/ML/DevTools Angel InvestorAI/ML Advisory Board member San Francisco, DevNetwork

🎩 Award-winning Open Source Engineer & Dev Advocate 🦊 Google Developers Expert Web DevRel 🚀 NASA Mars Ingenuity Helicopter mission code contributor 🏆 8th GitHub Stars Award recipient with 3x GitHub Stars Award (Listed as GitHub's #1 JavaScript trending developer).

🌳 Node.js foundation Community Committee Outreach Lead, Member Linux Foundation, OpenAPI Business Governing Board, and DigitalOcean Navigator. 📟 Teaching thousands of developers Node.js CLI Automation (100 videos · 22 Projects) & VSCode.pro course. Over 142 Million views, 22 yrs Blogging, 56K developers learning, 200+ FOSS.

✌️ Author of various open-source dev-tools and software libraries utilized by millions of developers worldwide WordPress Core Developer 📣 TEDx Speaker with 100+ international talks.

As quoted by: Satya Nadella · CEO of Microsoft — Awais is an awesome example for developers.
🙌 Leading developers and publishing technical content for over a decade 💜 Loves his wife (Maedah) ❯ Read more about Ahmad Awais.

👋… Awais is mostly active on Twitter @MrAhmadAwais

📨

Developers Takeaway

Stay ahead in the web dev community with Ahmad's expert insights on open-source, developer relations, dev-tools, and side-hustles. Insider-email-only-content. Don't miss out - subscirbe for a dose of professional advice and a dash of humor. No spam, pinky-promise!

✨ 172,438 Developers Already Subscribed
Comments 2
  • Fahad
    Posted on

    Fahad Fahad

    Reply Author

    Thanks for the post.
    Q. What if I have made tons of changes (that go way beyond style.css) in my theme without making a child theme? Now the developer is offering an update because its a premium theme but I can’t do it.
    Any solution other than doing the whole stuff again.


    • Ahmad Awais
      Posted on

      Ahmad Awais Ahmad Awais

      Reply Author

      Nope there is no solution, except fo you stripping out those changes and making them work with a child theme.