WordPress Themes
A theme controls the design and the layout of your site. When you change the theme, the content (posts, pages, media) stays the same, but the look of the site changes.
Classic themes and block themes
| Point | Classic theme | Block theme |
|---|---|---|
| Templates | PHP files (header.php, single.php) | HTML files with blocks in the templates folder |
| Design settings | Customizer and PHP code | Site Editor and theme.json |
| Menus and widgets | Appearance > Menus and Widgets | Navigation block and template parts |
| Example | Twenty Twenty-One | Twenty Twenty-Five |
New themes are mostly block themes, but millions of sites use classic themes and they are fully supported.
Themes on a fresh WordPress
$ wp theme list –fields=name,status,version
name status version
twentytwentyfive active 1.5
twentytwentyfour inactive 1.6
twentytwentythree inactive 1.7
$ wp theme get twentytwentyfive –fields=name,title,version,status
Field Value
name Twenty Twenty-Five
title Twenty Twenty-Five
version 1.5
status active
Where to get themes
- WordPress.org theme directory: free and checked themes, reachable from Appearance > Themes > Add Theme.
- Premium theme shops and developers: paid themes with support. Download only from trusted sellers.
- Custom themes: made by a developer for your site.
Install, activate and delete a theme
- Go to Appearance > Themes > Add Theme, search a theme and click Install.
- Click Activate. The theme is now live (use Live Preview before, if you want).
- To remove a theme you do not use, open its details and click Delete.
The same with WP-CLI:
$ wp theme install twentytwentyone
Installing Twenty Twenty-One (2.9)
Downloading installation package from https://downloads.wordpress.org/theme/twentytwentyone.2.9.zip…
Using cached file '/tmp/wpcache/theme/twentytwentyone-2.9.zip'…
Unpacking the package…
Installing the theme…
Theme installed successfully.
Success: Installed 1 of 1 themes.
$ wp theme activate twentytwentyone
Success: Switched to 'Twenty Twenty-One' theme.
$ wp theme list –fields=name,status
name status
twentytwentyfive inactive
twentytwentyfour inactive
twentytwentyone active
twentytwentythree inactive
$ wp theme activate twentytwentyfive
Success: Switched to 'Twenty Twenty-Five' theme.
$ wp theme delete twentytwentyone
Deleted 'twentytwentyone' theme.
Success: Deleted 1 of 1 themes.
Where is a theme saved?
Every theme is a folder inside wp-content/themes. The folder has at least a style.css file (it holds the theme details in a comment) and a template file. Keep one default theme installed as a fallback, in case your active theme breaks.
$ ls wp-content/themes/twentytwentyfive
assets
contributing.txt
functions.php
package-lock.json
package.json
parts
patterns
readme.txt
screenshot.png
style.css
style.min.css
styles
templates
theme.json
$ ls wp-content/themes/twentytwentyfive/templates | head -8
404.html
archive.html
home.html
index.html
page-no-title.html
page.html
search.html
single.html
The development chapters of this website explain the files in depth: Theme Files and Functions.