Folder Structure

The folder structure of ignition is similar to underscores or twenty seventeen. So if you have used those themes, you will feel at home.

The root folder has the main files that WordPress calls. These files get called based on the WordPress query. For instance if your are viewing a page, page.php is called. If you are viewing a post, single.php is called. And if you are viewing an archive index.php is called.

You can learn more here: 
https://developer.wordpress.org/themes/basics/template-hierarchy/

Template Parts

With ignition, almost all files in the root in one way or another end up pointing to the folder template-parts. Here is where the bulk of your editing will take place. Whether an archive is being called, or a single post, or even some small part of the site, like the site-top. Template-parts is where your main content lives. It’s probably where you will spend your time coding. In fact you may never have to touch the php files outside template-parts.

Routing to the right content

ignition is smart and routes almost everything to template-parts. For instance, single.php will load a header, a footer, and its main content in the middle. All these parts are found in the folder template-parts. This way when a developer comes along they know where to look when making content changes. Ignition is even smarter because it can route to a folder inside template-parts based on the post type. You can have a separate folder for each post type inside template parts and ignition will automatically load the right one.

Including from template-parts

If you’re creating your own files and plan on getting content from template-parts there is a function WordPress comes with. get_template_part(). You can learn more about it here: 

However this function does not let you pass variables from your current file to the file your getting. Instead, ignition uses this a lot:

include( locate_template( 'template-parts/path_to_file.php' ) );

This includes the file, while also checking to see if there is a child theme involved and makes sure to get the right file. It also allows you to continue using variables you have made without any problems.

Post Type Folders

As stated above, Ignition is smart and knows to get the right type of content based on the post type. If you open single.php, and index.php, you will see that ignition will tell it to look for the right post type and use the content from the folder with the same name as the post type. If ignition cannot find the right post type it will default to the folder “post”.

This means if you plan on adding a post type and want the content/html to be different, you can easily just make a new folder in template-parts with the new post type name. A good way to do this is to duplicate the folder “post” and use that as a starting point for a new post type.

This means making a new post type’s content is quite easy. You probably don’t even have to add a single-{post-type}.php file or an archive-{post-type}.php file to the root. Instead, index.php will route to the right post-type folder and so will single.php. You will only need to make those root files if you plan on doing some major changes to the rest of the site for those post types.

Content.php

Each post type folder in template-parts should have a file called content.php. By default there is only post types of “page” and “post”, but, as stated above, you can add your own. These content.php files output the content for that post type. Here is where you can actually spend time editing and changing how the post content will output. This is where you will probably edit the theme the most. The content.php code is conditionally split into two major parts:

  1. What to show on a single post or page
  2. What to show when this post is output in an archive or card list.

Card vs. Single view

WordPress doesn’t really have a name for what a post is called when viewing it NOT as a single. So we’re gonna call it cards from here on out 🙂

A card is the outside of a post where you will see an excerpt and a thumbnail inviting you to click and view the single full post. So if you create a query or are viewing an archive page, you will be seeing cards. And when you click one of the cards you will be seeing the single view.

Both views get the same file content.php. So WordPress needs to know what to show for both cases and that is why the file is split into two parts. You can open one to see how it works and how it is split.

Page Folder

The page folder is a bit different and has two files. One for the full page, the other for a card, when viewing this page in a list like a search page. This is because it could not have a conditional in one file to check if is_page() is true or not. This is because there are many plugins that just use page.php for all their work whether it’s a post type, or an archive. This would result in the wrong output, so the folder has two separate files.

And that is how the folder structure in ignition works.