Home Upgrade Search Memberlist Extras Hacker Tools Award Goals Help Wiki Contact

The best way to make a Wordpress theme: Part 1 - A new way to setup wordpress

Let me start this off by saying this is only in my opinion the best way to go about this. I'm also sure I am not the first person to end up with this workflow, but I just want to share it. :)

Also, check out my blog, I post a lot of tuts there and they look much nicer to read there imho: http://casual-coding.net/creating-your-f...wordpress/

I have been working with Wordpress for a significant amount of time now and over the years I have seen and tried a variety of different methods, plugins, frameworks and everything else under the sun to make theme development for Wordpress as painless as possible. More often than not it did not work out as planned and was just as painful as I had feared.

Over the last year I have been slowly putting together a method of developing wordpress themes that I have fallen in love with because of how fast it is to get set up. It is modular, powerful and great to work with. This guide is the first of a small series in which I aim to show you how to utilise my method to create wordpress themes. I will take you though the tools and technologies I use as well as explain as best I can why I decided to use these tools in my workflow.

The first part of this tutorial will be setting up Wordpress. I can tell many people are going to immediately roll there eyes and say "What the hell man, we all know how to install wordpress...", BUT DONT! I want to show you a killer way of doing it that is one command, super easy and fast, and has some really cool options to make your wordpress setup sweet!

[Image: r8zQ89n.jpg]

So without further ado we will get right into it and have our new wordpress setup within minutes.


Alrighty, so if you have read any of my tutorials before then you will probably know that I am a pretty big advocate of Yeoman. For those who dont know what Yeoman is, it is a tool that can be used to generate projects, usually used to scaffold out projects ready to quickly jump in and develop. We are going to use yeoman to scaffold out our wordpress project and take advantage of some of the easy and powerful options this approach gives us.

[Image: J2tpOhk.jpg]

You can easily install Yeoman by running the following commend in terminal or cmd with node installed

Code
npm install -g yo bower grunt-cli gulp

You can also learn more about Yeoman and how it works by going here and checking out some of the super simple documentation for it: http://yeoman.io/learning/

Ok cool so now you have Yeoman, or if you're awesome then you had Yeoman installed already. Yeoman by itself is simply a tool for scaffolding. Now what you need to get your hands on are some blueprints to give to Yeoman to build what you want it to build, which is this case is an awesome wordpress project. So now lets go and get ourselves some of that. Head over to https://github.com/wesleytodd/YeoPress and you will see a generator that Wesley Todd has created for Wordpress which is amazing. Feel free to spend some time checking out the details of it but we will be using it soon anyway.

You can install the wordpress generator using npm, just run this in terminal:

Code
npm install -g yo generator-wordpress

Now go into your sites folder and create a new folder for your wordpress installation. Inside of this folder we are going to run the Yeoman command to generate our wordpress site ready to roll.

Inside of your new site folder run the command to generate a new wordpress site:

Code
yo wordpress

Once you run the above you will be greeted with a sexy little ascii art and some questions to help the generator make the wordpress setup exactly how you want it. I will talk you through the prompts now.

Wordpress URL

This allows you to quickly set up a url for your development, like a virtual host.

Table Prefix

Set your database table prefix for multiple wordpress installs.

Database Host, name, user and password

Standard details for your database for wordpress to install itself into.

Use Git?

This makes the generator automatically initialise a git repo for your project. I highly recommend Yes for this because it gives you access to the below options.

Would you like to install Wordpress as a submodule?

This installs the wordpress core in a seperate folder from your themes, uploads and plugins. Very cool option and keeps your code modular and seperate. I suggest choosing yes for this.

Wordpress Install Directory

Its fine to leave this as default, unless you want to change the name of the folder the wordpress core is in. You could name it something like CMS if you want to hide the fact you're using wordpress.

Wordpress Content Directory

Same deal, this is fine default, feel free to change it to anything you like if you dont like the default name.

Install a custom theme?

This is a very cool feature that allows you to provide github details and automatically install a theme, you can even set a script to run on install to add even more automation. However for now we will not be using this since we will be installing our theme manually.


Its is also useful to note that if you pass the --advanced option into your yo wordpress command, it allows you further options like automatically setting up a Vagrant Box for your project, selecting a specific wordpress version, and adding the core wordpress to your .gitignore file.

Once Yeoman has finished chugging away and your project is created you should see your folder populated with this:

[Image: mrtE08y.png]

You are now done! You have a clean modular wordpress install, your core is separated from your content and you are ready to begin the next step, creating your new theme!

I hope you enjoyed the first part of this tutorial series and if you did then please feel free to share it around. PEACE!
Interesting... Never considered using a tool like Yeoman for WordPress. I've never really felt like I needed a tool to assist with WordPress though. The install process is quite easy - but your process does speed it up a bit. Pretty cool it can handle setting up Git, Vagrant, etc.

Correct me if I'm wrong - but how is that any more modular than a default WordPress install? WP core and your content have always been separated? (wp-content, wp-core, wp-admin)

Also, this is slightly irrelevant but I'm going to say it anyways. I've noticed a large majority of WordPress developers are not really... developers (in-depth, at least)? Many lean more towards the design/beginner coder side of things. I know I'm stereotyping and all that fun stuff, but these techniques don't seem to be something a majority of WordPress devs would use. I did WordPress development for 2 years, up until this past October, and that was what I observed among my peers who were developing for WordPress.
(Jan 14, 2015 07:36 PM)English_Fire Wrote:  Interesting... Never considered using a tool like Yeoman for WordPress. I've never really felt like I needed a tool to assist with WordPress though. The install process is quite easy - but your process does speed it up a bit. Pretty cool it can handle setting up Git, Vagrant, etc.

Correct me if I'm wrong - but how is that any more modular than a default WordPress install? WP core and your content have always been separated? (wp-content, wp-core, wp-admin)

Also, this is slightly irrelevant but I'm going to say it anyways. I've noticed a large majority of WordPress developers are not really... developers (in-depth, at least)? Many lean more towards the design/beginner coder side of things. I know I'm stereotyping and all that fun stuff, but these techniques don't seem to be something a majority of WordPress devs would use. I did WordPress development for 2 years, up until this past October, and that was what I observed among my peers who were developing for WordPress.

Lots of points there, ok ill try my best.

So firstly yeah I think Yeoman is particularly good for this kind of stuff, because it also runs heaps of other stuff, if you give it DB access it will even go make your database for you and put the details into wordpress.

Its more modular than the default wordpress install because your theme, plugins, uploads and everything else are split into 3 folders at a base level, its generally just cleaner but also helps with updating wordpress via git or changing versions whenever you need to, just rename the core folder and you're done.

As for the beginner thing with people developing with wordpress I have to agree with you to a certain extent. I usually lean the same way you do with my opinion on wordpress developers. However I find that regardless of where you work, sometimes a wordpress site pops up and having the skills to do it as painlessly as possible is never a bad thing to have.

Also I posted a wordpress tutorial because I think its more beginner friendly and nobody was replying on my more advanced web component tutorials. :3


Also this method of installing wordpress works particularly well with my next parts. You will see later I guess. :)
(Jan 14, 2015 08:25 PM)Tasemu Wrote:  Lots of points there, ok ill try my best.

So firstly yeah I think Yeoman is particularly good for this kind of stuff, because it also runs heaps of other stuff, if you give it DB access it will even go make your database for you and put the details into wordpress.

Its more modular than the default wordpress install because your theme, plugins, uploads and everything else are split into 3 folders at a base level, its generally just cleaner but also helps with updating wordpress via git or changing versions whenever you need to, just rename the core folder and you're done.

As for the beginner thing with people developing with wordpress I have to agree with you to a certain extent. I usually lean the same way you do with my opinion on wordpress developers. However I find that regardless of where you work, sometimes a wordpress site pops up and having the skills to do it as painlessly as possible is never a bad thing to have.

Also I posted a wordpress tutorial because I think its more beginner friendly and nobody was replying on my more advanced web component tutorials. :3


Also this method of installing wordpress works particularly well with my next parts. You will see later I guess. :)

Oh - alright. I didn't notice it split the folders event further. Very cool.

Makes sense. Hopefully whatever WordPress developer inherits the project later knows what to do! lol. WordPress sites are bound to pop up eventually for most web developers these days. I work at a company where everything (literally) is written with CakePHP for some reason, and was surprised to see a WordPress site being developed internally today!

Excellent choice with posting a WordPress tutorial. I read your other tutorials, and I actually had the same thoughts. A lot of the individuals who browse this forum are just getting into web development (or looking for free labor, lol), and this is probably a good topic for that audience.

Good luck! Hope people enjoy this little series you're cooking up.
Cheers man! I really appreciate that. Thanks for the morale boost, I will start working on the next part soon. :)


Possibly Related Threads...
Thread / Author Replies Views Last Post
by aSmooJan 30, 2013 01:38 AM 1 132 Jan 30, 2013 01:38 AM
Last Post: b001ean
by aSmooJan 7, 2013 01:43 PM 1 159 Jan 7, 2013 01:43 PM
Last Post: Titties Moist
by zombiemanNov 20, 2012 04:34 PM 7 195 Nov 20, 2012 04:34 PM
Last Post: 'Mewtwo