Functions.php is finally here on Let’s Build A WordPress Theme from scratch! Your functions template file in WordPress is really the engine behind your theme. It controls a lot of specific functions that you website will require to run, and for you to be able to better take control of it. The functions file is really limitless. You can go out and look for WordPress code snippets and 90% of those snippets will tell you to put them in the functions.php file. Because of this fact, I will only be covering generic functions that you can use to run your WordPress website.
WebTegrity’s WordPress Theme Development courses are taking off like a rocket! Spots are filling up left and right and we are getting ready to get everything up and running. This video explains our full 16 week course a little bit more in-depth. If you think you would benefit from learning WordPress or you have always wanted to become a coder and learn WordPress theme development, check out the Web360 program.
I also have a big announcement coming soon about WordPress and the San Antonio Community. We have been busy planning and setting up for a ‘first’ to hit SATX and we can’t wait to share it!
Moving right along in our eighth installment of the Let’s Build A WordPress Theme From Scratch tutorial series, we are going to be learning about the footer.php template file. This is a very important file, much like it’s counterpart header.php, because it repeats on every page. Plus it is the end of your document and the final thing viewers will see when they scroll to reach the bottom of the page. This is the last impression of your website to your audience so it is crucial that you put some good cross marketing, social media links, or additional calls to action so that people don’t just leave your website at that point. For example in my footer I have a subscription area because I would like people to subscribe if they have enjoyed the content (hint hint). Then I have some additional information and links to contact me. Other than what you see on the surface, the footer.php file will hold some really important functionality that we need to discuss. Let’s get to it!
If you have ever been interested in designing, developing, and optimizing websites for a living, you need to come learn WordPress in San Antonio. I have partnered with WebTegrity to be one of their lead instructors teaching a brand new WP course called Web360.
Today we are going to learn about Category.php and Tag.php as we continue this Let’s Build A WordPress Theme From Scratch tutorial series. This will be a fairly short and simply tutorial because these two template files are very straight forward. As I am sure you know by now, WordPress allows you to add categories and tags onto posts. I have already shown you how to display those on the home.php template and the single.php template. If you are actually building along with this WordPress theme tutorial you probably noticed that categories and tags are links. When you click on a specific tag or category they display all the posts that are within that specific category or tag. I’m sure you can see what is coming next.
Sidebar.php is the next template file we will learn in our Let’s Build A WordPress Theme From Scratch tutorial series. As I am sure you have guessed from the name of the file, it handles the code that displays the content of your sidebar. Sidebars have been a common structural element in websites for years. Really anything can go in a sidebar but I prefer to “widgetize” my sidebars so that the user/client can dynamically include/change what displays. Widgets come standard with any WordPress install and give you the ability to drag and drop mini-plugins into your website and have certain things happen: like maybe a contact form or a dynamic list of categories. These can also be extended by searching the plugins section of WordPress to find more. When you build a WordPress theme you should always think about what type of functions you might want or need and go out and research plugins that might accomplish your needs. Once you have all of the widgets you want…you need to have a “widgetized” area ready to drag those widgets into so they display on your website. We are going to talk about how sidebars work in WordPress and how we can create these widget areas so they can be used throughout your build.
In today’s Let’s Build A WordPress Theme From Scratch tutorial we are going to go back and look at the blog and work with single.php. We talked about home.php in my second article in this series and how it controls/displays your most recent posts. When you come to wpdevsolutions.com, the landing page of my website displays the most recent articles I have written. This means that I am using home.php to display those posts. You have now clicked into this article and can now read the full tutorial. You are currently on single.php! It contains a lot of the same information we have seen in other php files but I will show you how we have to change up the code just a little in order to show the full content and a few helpful items you should include on a single.php file. Let’s look at the code from my theme from scratch example.
Today on Let’s Build A WordPress Theme From Scratch, our tutorial will look at the template file page.php which controls what is displayed on each of your pages. As you know, in WordPress there are posts and there are pages. When we build a WordPress theme we need to think about them separately because there are php templates that hold the code for the blog/posts and others that hold the code for the pages. For pages there is actually only page.php but there are instances where you would use a variation of it. For example, what if you don’t want every single page on your website to be structured and styled the same way? WordPress has you covered! It has the most intuitive naming scheme on the planet, in my opinion, and it allows you to do very powerful things. As you will notice later in the course, this naming structure works for many other template files as well. Let’s dig into it!
Are you ready to dig into another installment of Let’s Build A WordPress Theme From Scratch? Today we are going to talk about another three files that if used together can really be an asset if your viewer happens upon a page that doesn’t exist. We all want to be well oiled machines when we develop and try to never forget anything but sometimes, even we make mistakes. So we need to take the proper measures to prevent one of our mistakes affecting our audience. This is accomplished by setting up a 404 error page. In WordPress we use a template file called, you guessed it, 404.php. There isn’t any mandatory code that needs to appear in this template file. It doesn’t have to be anything special, but I recommend that you do make it special! Even as developers we need to think about a user’s experience. If they have landed on a broken link then that is already not a very good experience on your website. You want to add in a statement that is lighthearted, plus provide them a few options of how to get to where they were trying to go. This is your chance to use slight of hand to make your viewer unaware they landed on a broken page on your website. Let’s look at the code for the 404.php file below.
Continuing with my full tutorial on building a WordPress theme from scratch, I will be talking about three very important files: home.php, front-page.php, and index.php. I am combining these three into one tutorial because based on decisions you make will determine which of these files will be your “landing page”. Think of it in terms of regular, static html sites. We typically put everything inside of the index.html file and your browser knows that this is the file to look for. In WordPress it is a little different because it is based on specificity. HUH!?! Yeah I just through that word in there to see if you were paying attention. What I mean, in plain English, is that the more specific you are with your naming of files the better WordPress knows what you are telling it to do with that particular file. None of this is going to make sense until I show you a few of the important options WordPress needs to know before starting development. Let’s dig in a little deeper.