Chủ Nhật, 21 tháng 2, 2016

How to create a Theme from Underscores starter wordpress theme


Once WordPress is up and running on your computer, you need to get a copy of the underscores theme. Underscores is a starter themebuilt specifically to be used as the starting point for new custom themes. It's in constant development, and you'll often see changes to the code base on a daily basis. This means, by using underscores, you'll always be working with the latest and greatest WordPress has to offer,what's often referred to as the 1000-hour headstart. However, it also means, that as the theme changes, you may have to adjust your process accordingly. You know that saying from the philosopher Heraclitus, that "No man ever steps in the same river twice," well, it applies here in a very big way.
Underscores is a river, and every time you step into it, or download it, you are experiencing a new underscores. The version you downloadwill always be number 1.0.0, and once downloaded it ceases being underscores, and becomes instead, your personal custom theme. I think that's enough philosophy for now. Underscores is available from the official site at underscores.me, and you can also get it directly from the github repository, at github.com/automatic/_s.
But for everyday use, you'll always get underscores from underscores.me. Following this course, you now have two options. Use the version of underscores provided in the exercise files to match my code exactly. You can pull those exercise files directly down from the github repository for this course. Or, get a fresh copy of underscores directly from underscores.me. If you choose the latter option, you may have to adjust your code slightly for it to work the same way mine does. The functionality will be the same, but small parts of the actual code may be slightly different.
However, using a fresh copy of underscores, directly from underscores.me, gives you the real experience of building a new theme from scratch using underscores. And after finishing this course, that's what you'll be doing every time you build a new theme. If this is the first time you're building a new theme, you may want to use the bundled version. If you already have some experience with themes, or you want the added challenge, go ahead and get a fresh copy. To start the process of building a new WordPress theme using underscores, I always start at underscores.me.
From here, we can setup a base theme that's pulled directly from the github repository, and we can fill in some basic information. Here you can see you can put in a name, so you can put in any name you want, I'm going to put in popperscores as my name. Then you can option advanced options, and fill in more information. The first one is theme slug, so that is what the machine-name of the theme is. Here it's a good idea to create a theme slug that matches the theme name. However, there's one important thing here. If you put in a theme slug that matches an existing theme, let's say 2016, you'll notice that once installed, WordPress will want to update your theme, and if you run that update, you'll actually get the 2016 theme, not your custom theme.

So, make sure that you create a new theme slug that is unique and is not already available in the WordPress theme directory. So I'm going to call this one popperscores. Then I'll put in my author name, an author URI, and a short description. If you like using Sass for your CSS, you can also choose to sassify the underscore starter theme, but we're not going to do that in this course. Once all the information is filled out, I click generate. This grabs the code from github, inserts all this new information, and then creates a new zipped folder for me that I can open, that contains a folder, with the themes like I just created.
Now that I have the theme on my computer, I can simply open my WordPress install, wherever it is on my computer, then go to the wp-content folder, the themes folder, and drag and drop the popperscores folder into the themes folder. Once that's done I can go back into my browser, log into my local WordPress site, go to appearance and themes, and here you see popperscores is now an option. Right now, the thumbnail for my new theme is blank, because the theme has no appearence yet, and if I activate it and go to the front end of my site, you'll see the site looks quite terrible.
It's just basic text and nothing else. Now this may be a bit jarring the first time you see it, but this is exactly where you want to start. Now you have free reign to do whatever you want with your own custom theme.

Không có nhận xét nào:

Đăng nhận xét