Build and activate a minimal classic theme
Description: Make a theme folder my-first-theme with a style.css (with the theme name) and an index.php that prints the site name in an h1 tag. Activate it and check the home page.
Hint:
- The theme name goes in a comment at the top of
style.css. - Use
bloginfo( 'name' )to print the site name.
Solution
/*
Theme Name: My First Theme
*/
<h1><?php bloginfo( 'name' ); ?></h1>
Terminal output
$ wp theme activate tc-my-first-theme
Success: Switched to 'My First Theme' theme.
$ wp theme list –status=active –fields=name,title
name title
tc-my-first-theme My First Theme
$ curl -s http://example.com/
<h1>Demo Site</h1>
How it works
- WordPress finds a theme when there is a folder with a
style.csswhich has aTheme Name. index.phpis the fallback template, so it is used for every page.
Read Theme Files and Functions.
Learn more about the similar topics:
| Tutorials |
|---|
| WordPress Themes |
| WordPress Top Theme List |
| WordPress Theme Files and Functions |
| WordPress Template Hierarchy |
| WordPress Enqueue Scripts and Styles |
| WordPress Loop |
| WordPress WP_Query Class |