0

In this video we’re going to talk about what exactly a WordPress theme is and the role it plays in a WordPress site. This is called Learn WP theme dev after all, so let’s dive right in.

In WordPress terms, a theme is responsible for handling the look and feel of your site. So the code in your theme is typically made up of templates, stylesheets, and scripts. However many themes also include functional code for things like registering new post types or hooks.

In my decade-plus of making WordPress sites, I’ve found that often times functional code is included in a theme. While this may not be the preferred official convention, many times it is convenient to have all of this code in the theme instead of 2 separate places.

My general take on this is that you should use your best judgment and err on the side of simplicity, especially if your theme is smaller or less complicated. If you’re building functionality that only works with your specific custom theme, having that code in a separate plugin becomes less valuable since that plugin can’t be used on its own and the theme your building isn’t packaged for redistribution.

If you’re creating custom Gutenberg blocks for your theme you can house these inside your theme or inside of a plugin. Lately, I’ve found that having them in the theme makes sense if the blocks would only ever be used with your theme. But if they’re ever intended to work with another theme, you should probably define them inside a plugin. We’ll cover all of these nuances in future videos, so no worries is that sounds confusing now!

So to recap: your theme is primarily responsible for the look and feel of your site.