Making a new wordpress theme from scratch

Making a new wordpress theme from scratch

Making a wordpress theme from scratch can seem daunting, but its pretty easy if you know the steps. Fortunately wordpress is really well documented. We have a starting point laid out for us:
https://wphierarchy.com the wordpress template hierarchy tells us every file we need to create for every scenario.

Starting from the right we can make the following files:
index.php
style.css
functions.php

We can then look at primary templates (you only really need to make these):
index.php
home.php
archive.php
search.php
singular.php
single.php
page.php
404.php

Secondary templates (if not present, the corresponding primary template will be used)
These are great if you want a different layout or components eg in your author pages from your tag pages
front-page.php
author.php
category.php
taxonomy.php
date.php
tag.php
attachment.php
single-post.php

Post types:
Post (Post Type: ‘post’)
Page (Post Type: ‘page’)
Attachment (Post Type: ‘attachment’)
Revision (Post Type: ‘revision’)
Navigation menu (Post Type: ‘nav_menu_item’)
single-post.php
single-page.php
single-attachment.php

Attachment Mime types: wordpress also supports mime type tempaltes:
image.php
video.php
pdf.php
text.php

WordPress recommend following the twentyseventeen file hierarchy:
https://developer.wordpress.org/themes/basics/organizing-theme-files/

Screen Shot 2018-07-07 at 19.49.58

Putting it all together you end up with:

assets (dir)
– css (dir)
– images (dir)
– js (dir)
inc (dir)
template-parts (dir)
– footer (dir)
– header (dir)
– navigation (dir)
– page (dir)
– post (dir)
languages (dir)
404.php
archive.php
comments.php
footer.php
front-page.php
functions.php
header.php
index.php
page.php
README.txt
rtl.css
screenshot.png
search.php
searchform.php
sidebar.php
single.php
style.css
—–
optional:
author.php
category.php
taxonomy.php
date.php
tag.php
attachment.php
—–
optional:
single-post.php
single-page.php
single-attachment.php
—–
optional:
image.php
video.php
pdf.php
text.php

* A note on version control. when starting a new theme (or any software project) start with your version control. doing so at the beginning and committing regularly will ensure that you have everything going back to the start of your project.

* A note on development environment. there are tons of great tools available today. use them. use them all. vagrant is fantastic. use it.