If you have been developing WordPress themes for a considerable amount of time, you will realize that you tend to reuse some—or most—of your code across projects. If you are like many of us, you might also have a starter/base theme that you use every time you start a new project.
You might even have a
functions.php file to
which you add functions and snippets, as well as link entire code libraries (such
as TGM Plugin Activation, WP Bootstrap Navwalker, etc). And you probably have
plugins and widgets (your own or downloaded from the WordPress repository) that you use in many of your projects.
All of these form your framework—a generic and ideally solid foundation upon which all your themes are built.
WordPress theme frameworks have been a hot topic for a while. Whether you should be using one is no longer the question. The benefits of using a theme framework cannot be denied and there are many, many frameworks out there; some are free, some premium.
The question is, which one should you use?
Which one you end up using will depend
largely on your needs, skill level, and other factors such as the front-end
framework used. Instead of guiding you in selecting the best theme
framework for you, I’m going to propose that you build your own.
In this series, I’m going to walk you through the process of creating your own WordPress theme framework by combining tools that you are most probably already familiar with. The basis/core of this framework will be Bootstrap and Underscores.
In this series, we will cover the following topics:
In this article, we are going to have a look at theme frameworks: what they are, what they are made of, and the advantages they afford the developer. We are also going to look at why you should build your own WordPress theme framework.
The WordPress Codex describe a theme framework as:
A "drop-in" code library that is used to facilitate development of a Theme, or a stand-alone base/starter Theme that is intended either to be forked into another Theme, or else to be used as a Parent Theme template
A theme framework contains a collection of code libraries that include at the very least an options page—which gives you, as a theme developer, the ability to give the end users of your theme some control over the look and feel of the theme without any coding knowledge.
Examples of code libraries commonly included in a theme:
A base/starter theme is a bare-bones theme that can be used as a foundation for the creation of your own themes.
A theme framework is a solid skeleton that consists of both a starter theme and some code/functionality which can
be used as starting point when developing WordPress themes.
A good framework is:
These apply both to standardized frameworks and to the ones you create for your own use.
A good framework includes the following functionality:
A WordPress theme framework has the following advantages:
You might be asking yourself, “Why build your own framework when so many free and commercial frameworks already exist?” Well, to answer that, let’s first have a look at the disadvantages of standard theme frameworks:
You would want to build your own framework to overcome some or all of the disadvantages mentioned above. Your own theme framework is better than any other for the following reasons:
In this article, I introduced the series as well as a road-map we are going to follow as we proceed. I also looked at WordPress theme frameworks: what they are, what they consist of, and their advantages. The last part of the tutorial built the case for developing your own theme framework.
Throughout this series, we will be building a theme framework that combines tools that most developers are already familiar with. The framework will also incorporate the features and components mentioned in this article, as well as ensuring that it affords you the advantages outlined above.
In the next article in this series, we’re going to have a look at Underscores.