Being a WordPress developer I build a lot of sites and getting things started can take a lot of time. Getting your site, themes plugins etc. ready to go, seems to always take longer than it should, as well as being something that we keep repeating. I therefore went about solving this in a fairly low level simplified way. What I created, I am calling WP Skeleton.
View WP Skeleton Code Repository on Github
As I use Git (in the flavour of Github) for my projects I thought that it might be a good idea to create a Github repository as a starting point. I could then fork or just download a ZIP this repository each time I wanted to get started with a project. This is the approach I have taken and the results can be viewed here: https://github.com/wpmark/wpskeleton
I think it makes sense to explain a bit about the setup that I am using here, to make sure it is clear. As you will notice the root folder does not look like a standard WordPress install. I have tweaked things a little in order to suit both my development style and just to keep things a little cleaner in the root of the project.
You may know that WordPress contains a
wp-content folder which contains all of the installs themes, plugins and uploads (all the content funnily enough!). WordPress gives you the ability to change the location of this content folder and therefore I have taken advantage of this and put everything in a content folder in the root. To do this you need to add the following to your
Moving WordPress to its Own Folder
Along with this, WordPress itself can be moved from the root directory to a sub folder, again keeping things a little cleaner. You can find more information on the Giving WordPress its Own Directory on the codex. Essentially you need the following change to the
I put WordPress in a folder named cms, and therefore there is a small change to bootstrapping WordPress adding this folder at the end. The other change is once you have WordPress installed you need to change the Site Address (URL) options in the Settings > General section of the admin to remove the
/cms part, as otherwise this would be included with all your sites URLs (permalinks).
For those not aware, in the
content now for us) you can have a folder named
mu-plugins. This means must use plugins and any plugins added in here will be run without activating them. Therefore I have a number of plugins in here that I use all the time and are not in the WordPress plugin repository. This is important because plugin residing in
mu-plugins must be updated manually and therefore if a plugin does exist on the WordPress.org plugin repository I want to update it from there.
You will see I have John Blackbourn’s excellent Extended CPTs and Taxonomy scripts in there for easily adding new Custom Post Types and Taxonomies as well as the custom meta boxes ‘framework’ amongst other things.
The final thing to mention is local development. Here we are committing the
wp-config.php folder to the repository and therefore this would not work for local development as the database details would be different. To get around this the
wp-config.php file is slightly different, in that we first check for the presence of a
local-config.php file which is ignored by Git. If this is present we require it and if not we use the normal database connection details (the live sites details). The
local-config.php can be added by any other developers wanted to use the site locally on their computer. In this file are also some constants to tell use we are in local development. We can use then to test against if we need to in any code.
So there we have a skeleton starter to work from for building WordPress sites from. The next thing I want to look at is getting WordPress to clone from the WordPress git repository when you fork the repository, which I believe is done with submodules. I am yet to get that far in my learning.
How do you go about building your WordPress sites? I would love to hear from you.
Leave a Reply