We'll look at the minimum requirements to create your own theme. With two files, style.css and index.php, you have all you need to get started. We'll look at how to pass information about the theme to WordPress and how to set-up a direct link to the admin panel.
Kevin Cunningham: [0:00] If I want to create a standalone-theme, one that doesn't rely on a parent, then I need to create two files rather than one. I'll create a directory in my themes directory for my standalone-theme. The two files I'll create are a style.css file, like we do for a child theme, and an index.php.
[0:22] For the moment, I'm leaving both of those files blank, but when I refresh my theme menu, you can see it is available here. Again, WordPress has named the theme based on the folder that I've created, and the rest of the information is left blank. I'm going to copy over the comment block I used for the child theme.
[0:43] I'm going to remove the line that says that this is a child theme, the template line. I'll claim this is a stand-alone theme. This is a stand-alone theme, and it's not based on anything. I've got my information.
[1:03] As for the child theme, I can copy in the screenshot.png into this folder. When I refresh, it goes in its rightful place.
[1:13] If I activate this theme and view the frontend, there's nothing there. We haven't told WordPress how to display any content, but if you're working in a headless environment, that's OK, because all of the headless functionality is still available.
[1:30] Rather than being presented with a blank screen here, let's add a link to the backend. In my index.php, I'll add html block. I'll say, this is for my Headless WordPress Instance, and I'll have a link.
[1:44] I want this to link to the admin_url. Generally, this is at wp-admin, and that works fine. However, it's sometimes a good idea to move the admin panel somewhere else, either for security or convenience or based on some other principle that you're using.
[2:01] Rather than hard coding the URL, I can use a PHP statement. In this PHP block, I want to echo an esc_url, and that esc_url is URL that's returned from the function admin_url(). Let's try that. There's no visible difference. Clicking on the admin still works.
[2:23] If within my WordPress instance I move the admin to be somewhere different, that link will always work.
Member comments are a way for members to communicate, interact, and ask questions about a lesson.
The instructor or someone from the community might respond to your question Here are a few basic guidelines to commenting on egghead.io
Be on-Topic
Comments are for discussing a lesson. If you're having a general issue with the website functionality, please contact us at support@egghead.io.
Avoid meta-discussion
Code Problems?
Should be accompanied by code! Codesandbox or Stackblitz provide a way to share code and discuss it in context
Details and Context
Vague question? Vague answer. Any details and context you can provide will lure more interesting answers!