Creating a Custom Theme

Learn to create a custom theme file for WordPress websites.

Theme files

A web page is composed of different chunks where we have a header, navigation links, main content, sidebar, comments sections and footer. A theme contains multiple files that control the styling and content of these sections. While there may be a large number of files in a theme, two files are compulsory.

  • style.css: This is the master stylesheet of the theme.

  • index.php: This is the fallback file to display all web pages of the website.

A theme can have other files, which are listed below:

  • functions.php: A pure PHP file which directs the WordPress system to initiate certain features and override the defaults.

  • single.php: Displays the individual posts.

  • page.php: Powers the static pages of the website.

  • header.php: Displays a global header on all web pages of the website.

  • footer.php: Displays the footer and loads JavaScript files.

  • front-page.php: Powers the main landing page of the website.

  • archive.php: Displays posts in a hierarchical format.

  • search.php: Displays the search results

  • comments.php: Displays comments on a post.

  • 404.php: Displays a custom 404 not found error page.

Organizing theme files

Get hands-on with 1400+ tech skills courses.