I have decided to make a WordPress theme, because I will learn about php and databases in the process, even if I am not successful. In addition, I will be able to make more alterations with other themes in the future by learning, building, and designing in WordPress.
I am nervous about this project, because I may be a little too ambitious. In addition to learning new web technology, I will have to go through a whole design process of wireframes and website development. I am thinking about either making something very simple or trying to make something specifically for people designing portfolio websites.
My goals include:
- Designing a WordPress theme.
- Learning more about php.
- Learning more about databases.
Documenting My Process:
Learning about php
I began my learning process with getting lost in links about php. I wanted to gain a basic understanding of php before I went straight into designing to help make my overall learning experience less frustrating.
Now I understand with greater depth how php uses the Loop to call files from a database and display them on a screen. The most important part of WordPress is The Loop. The Loop makes a query call to blog posts in the WordPress database to display them.
The most crucial sites for my learning and project were: https://codex.wordpress.org/Class_Reference/WP_Query, https://www.smashingmagazine.com/2016/01/create-customize-wordpress-child-theme/, https://www.smashingmagazine.com/2015/06/wordpress-custom-page-templates/, and https://codex.wordpress.org/Stepping_Into_Template_Tags.
After learning about php making calls to a database, I began learning about the basic syntax of php. You can alter the Loop or declarations based on the commands you put inside the () of a php call. An index.php or page.php file often call other .php files as building blocks to form a website. For instance, the header code, footer code, and sidebar code will all be in separate files and compiled together by the main index or page files. For increased customization, different templates can be applied to page.php files. Since you can alter Loop declarations, you can write the php Loop to only display certain blog categories. This knowledge became one of the biggest focuses of my project.
First Steps to Designing
The design process began with wireframes and I was excited make my own WordPress theme. However, I quickly discovered that creating a whole theme is not realistic or timely for the final project. As a result, the discovery of child themes became the new focus for my project. Child themes can be created to make adjustments to a current theme already on WordPress. So, I decided to alter the Hemingway theme.
I was successful in creating my Hemingway Child Theme buy uploading a folder in the themes folder of cpanel. Within the folder, the two necessary files for the creation of the child theme were a functions.php and style.css file. Through https://wordpress.org/themes/ I downloaded the Hemingway parent theme to begin making alterations. By using the structure of the original stylesheet I could make organized changes in my own stylesheet. In fact, I originally only used the functions.php file to make sure the Child Theme would link to my stylesheet before the parent stylesheet.
Thus began the changes to my Child Theme: First up, changing the header and navigation colors for greater accessibility. I also made the blog text a couple points smaller, because I thought the text was large for body paragraphs. Next, I changed the default header photo by adding more code to the functions page and adding a picture to my cpanel folder.
Working with The Loop and Templates
Then came trying to make more robust changes. I wanted to make a child theme that could be used for portfolios. Using the Loop, I planned to make a blog category and style specifically for portfolio entries. Signifying the portfolio page with a Loop only calling on the portfolio category would allow professionals to display their work easily. However, this proved to be difficult. First, I tried to add code to the functions.php page that was supposed to make a new post type called projects. I thought this would be ideal, because then I would be using a different loop in general instead of trying to display only one loop on a page. After receiving fatal error after different fatal error, I figured that maybe this was not the right option for me at my current level.
Next I switched to making a page template file that could be applied to any page a user would desire to have a portfolio on. Again, I tried to use the loop. At first, my fatal errors wouldn’t allow the WordPress child theme to render at all, but with adjustments I was able to get fatal errors only on rendering the blogs on the portfolio page. I figured that meant I was headed in the right direction.
I emailed Professor Hart and he responded with resources to continue my process of receiving different fatal errors. While I could not come to a success, I gained a respect for php coders and found more resources for learning in the future. Professor Hart directed me to https://wordpress.stackexchange.com/questions/6731/if-is-custom-post-type and https://phpcodechecker.com/.
Without much success on my portfolio page, I decided to take the success of forming my first WordPress Child Theme and my fatal errors for learning in the future.
Overall, I have achieved most of my goals. I have most definitely learned more about php, since I came in knowing virtually nothing. I also understand more in depth how databases render information on the web. I have not created a whole WordPress theme, but I have stepped into the gateway of WordPress theme development through Child Theme development. What I have gained most is realizing even if my Child Theme is not officially loaded to the WordPress directory, the creation of a Child Theme gives you greater power to implement the changes you want on a WordPress site without having to worry about an update wiping out your changes. Child themes are convenient, because any file with the same name as the parent theme will override the original code (with the functions file as an exception). The creation of Child Themes will be something I need to explore more in the future.