my-theme/
│
├── style.css
├── index.php
├── functions.php
├── screenshot.png
├── readme.txt
│
├── header.php
├── footer.php
├── sidebar.php
├── front-page.php
├── home.php
├── page.php
├── single.php
├── archive.php
├── category.php
├── tag.php
├── search.php
├── 404.php
├── comments.php
│
├── template-parts/
│ └── content.php
│
├── assets/
│ ├── css/
│ ├── js/
│ └── images/
│
└── languages/
✅ MAIN FILES IN EVERY THEME
1. style.css
- Required: Yes
- Purpose: Contains the theme metadata (name, author, version, etc.) and the main CSS styles.
2. index.php
- Required: Yes (Acts as a fallback)
- Purpose: The main template file. Used if a more specific template (like
single.php,page.php, etc.) isn’t found. - Loads: Posts, pages, or any content as a fallback.
3. functions.php
- Required: No (but strongly recommended)
- Purpose: Add theme features and hook into WordPress core functions.
- Common usage:
- Register menus
- Add theme support (e.g.,
post-thumbnails) - Enqueue styles and scripts
- Create custom functions
4. screenshot.png
- Required: No
- Purpose: A preview image shown in the WordPress dashboard under Appearance → Themes.
- Size recommendation: 1200×900px
5. readme.txt
- Required: No
- Purpose: Documentation for the theme. Usually contains info like version history, author, and usage notes.
✅ TEMPLATE FILES
These files control how different types of content are displayed:
6. header.php
- Purpose: Contains the HTML
<head>section and site header (logo, navigation). - Included in: Most templates using
get_header()function.
7. footer.php
- Purpose: Contains closing HTML tags and the site’s footer content.
- Included in: Most templates using
get_footer()function.
8. sidebar.php
- Purpose: Displays the sidebar with widgets or links.
- Included in: Templates using
get_sidebar().
9. front-page.php
- Purpose: Used when a static front page is set in WordPress.
- Overrides:
home.phpandindex.phpfor front page display.
10. home.php
- Purpose: Displays the blog posts index page when no static front page is set.
11. single.php
- Purpose: Displays single blog posts.
12. page.php
- Purpose: Displays individual static pages (like About, Contact).
13. archive.php
- Purpose: Displays archive pages (categories, tags, authors, dates).
14. category.php
- Purpose: Specifically displays category archive pages.
- Overrides:
archive.phpfor categories.
15. tag.php
- Purpose: Specifically displays tag archive pages.
16. search.php
- Purpose: Displays search results.
17. 404.php
- Purpose: Displays a custom error page when content isn’t found.
18. comments.php
- Purpose: Displays the comments section and comment form.
- Used in:
single.php,page.php, etc.