Creating a Custom WordPress Theme – Part 2

Let’s continue our journey in creating a custom WordPress theme with Part 2 and take your theme-building skills to the next level

Roberto Tejeda

Estimated reading time: 2 minute(s)
July 9, 2024

It is recommended to read Creating a Custom WordPress Theme – Part 1 first.

Required files to actually see something on the front end

header.php

In WordPress, the header.php file is a crucial template file that controls the structure and content of the header section of a website. It typically includes essential elements such as the <head> section with metadata, title tags, links to stylesheets and scripts, and other header-related functionalities like navigation menus and the site logo.

Developers often place functions that generate dynamic content or handle conditional logic specific to headers in this file. This file contains the top part of our pages, that’s why some tags will remain opened (they will be closed in the footer.php file).

PHP

Similarly, the footer.php file in WordPress is a template file that governs the content and structure of the footer section across a website. It typically contains elements like closing tags for </div>, </main> and </body> containers, scripts for JavaScript functionalities, footer navigation menus, social media icons, copyright information, and any other content that should appear consistently at the bottom of every page.

Developers often include dynamic content generation functions or widgets specific to footers in footer.php, ensuring that these elements are uniformly applied throughout the WordPress theme and providing a cohesive user experience from top to bottom of the website.

PHP

page.php

In WordPress, page.php is a default template file that dictates the structure and layout of individual pages on a website. When a visitor accesses a specific page, WordPress uses page.php (if available) to render its content. It includes the header and footer components (via get_header() and get_footer() functions) to maintain consistency with the rest of the site. It also contains the main content area where the actual page content, such as text, images, and other media, is displayed. This content is displayed using the_content() function from WordPress.

Developers often embed conditional tags or custom loops within page.php to handle different types of pages or to display specific content based on certain conditions.

PHP

Create a new page

We are going to create a page to make sure all files and pieces are correctly used.

  1. Go to WordPress dashboard.
  2. Go to Pages > Add New Page
  3. Create a new page.

Add content: text, images, etc. The publish it.

The page may still not look as “finished”. We still need to add styles and other things. So far this is the basic structure of a default page template.

Part 3 will include using Bootstrap to style our new theme.

Share this post: LinkedIn LinkedIn Logo Facebook Facebook Logo

About Aviada

With Aviada’s expertise in staff augmentation, hiring professionals in Mexico has never been easier.
By providing us with a job description, you can harness the benefits of Employer Of Record Services and trust Aviada to locate the ideal candidate to meet your needs, seamlessly taking care of the entire process.

Aviada ranked #1 in Best Place to Code 2021

Best Place to Code® is a program to identify and award companies that make efforts to offer the best work conditions to IT Professionals. This award is operated by Software Guru.
BPTC Logo