Bird
Raised Fist0
Wordpressframework~20 mins

Style.css and theme metadata in Wordpress - Practice Problems & Coding Challenges

Choose your learning style10 modes available

Start learning this pattern below

Jump into concepts and practice - no test required

or
Recommended
Test this pattern10 questions across easy, medium, and hard to know if this pattern is strong
Challenge - 5 Problems
🎖️
Style.css Metadata Master
Get all challenges correct to earn this badge!
Test your skills under time pressure!
🧠 Conceptual
intermediate
2:00remaining
What is the purpose of the Style.css file in a WordPress theme?

In WordPress themes, the style.css file contains important information. What is its main purpose?

AIt stores the images and media files used by the theme.
BIt contains the PHP code that runs the theme's backend logic.
CIt holds the theme's CSS styles and metadata like theme name and author.
DIt manages the database connections for the theme.
Attempts:
2 left
💡 Hint

Think about what controls the look and basic info of a theme.

📝 Syntax
intermediate
2:00remaining
Identify the correct theme metadata header in style.css

Which of the following style.css headers correctly defines the theme name and author?

A
// Theme Name: My Cool Theme
// Author: Jane Doe
B
/*
Theme Name: My Cool Theme
Author: Jane Doe
*/
C
<!-- Theme Name: My Cool Theme
Author: Jane Doe -->
D
# Theme Name: My Cool Theme
# Author: Jane Doe
Attempts:
2 left
💡 Hint

WordPress expects the metadata in a CSS comment block.

component_behavior
advanced
2:00remaining
What happens if the theme metadata is missing in style.css?

If a WordPress theme's style.css file lacks the required metadata header, what will WordPress do when you try to activate the theme?

AWordPress will delete the theme files automatically.
BWordPress will activate the theme but show a warning message.
CWordPress will activate the theme normally without any issues.
DWordPress will not list the theme in the Appearance > Themes page.
Attempts:
2 left
💡 Hint

Think about how WordPress recognizes themes.

🔧 Debug
advanced
2:00remaining
Why does this style.css metadata cause the theme to be unrecognized?

Look at this style.css header snippet:

/*
Theme-Name: Awesome Theme
Author: John Smith
*/

Why does WordPress fail to recognize this theme?

ABecause the metadata key <code>Theme-Name</code> is incorrect; it should be <code>Theme Name</code> without a dash.
BBecause the file is named style.css instead of theme.css.
CBecause the comment block is not closed properly.
DBecause the author name is missing an email address.
Attempts:
2 left
💡 Hint

Check the exact spelling of metadata keys.

state_output
expert
3:00remaining
What is the output of this style.css metadata block in WordPress theme info?

Given this style.css metadata block:

/*
Theme Name: Simple Theme
Theme URI: https://example.com/simple-theme
Author: Alice
Author URI: https://example.com
Description: A simple WordPress theme.
Version: 1.0
License: GPLv2 or later
License URI: https://www.gnu.org/licenses/gpl-2.0.html
Text Domain: simple-theme
Tags: light, two-columns, responsive-layout
*/

Which of the following is true about how WordPress displays this theme in the dashboard?

AThe theme will show the name 'Simple Theme', author 'Alice', version '1.0', and tags including 'responsive-layout'.
BThe theme will show the author 'Alice' but no theme name or description.
CThe theme will show the name 'Simple Theme' but no author or version info.
DThe theme will not appear because the metadata is too long.
Attempts:
2 left
💡 Hint

WordPress uses all standard metadata keys to display theme info.

Practice

(1/5)
1. What is the main purpose of the style.css file in a WordPress theme?
easy
A. To configure WordPress user roles
B. To store the theme's PHP functions
C. To manage WordPress database connections
D. To hold the theme's styles and metadata information

Solution

  1. Step 1: Understand the role of style.css

    The style.css file contains CSS styles that define the look of the theme.
  2. Step 2: Recognize the metadata block

    It also includes a metadata comment block that tells WordPress about the theme's name, author, and version.
  3. Final Answer:

    To hold the theme's styles and metadata information -> Option D
  4. Quick Check:

    style.css = styles + metadata [OK]
Hint: Remember style.css holds styles plus theme info [OK]
Common Mistakes:
  • Confusing style.css with functions.php
  • Thinking style.css manages database or users
  • Ignoring the metadata block in style.css
2. Which of the following is the correct way to start the metadata block in style.css for a WordPress theme?
easy
A. /* Theme Name: My Theme */
B. // Theme Name: My Theme
C.
D. # Theme Name: My Theme

Solution

  1. Step 1: Identify CSS comment syntax

    CSS comments use /* ... */ to enclose text, including metadata.
  2. Step 2: Check WordPress metadata format

    WordPress expects metadata in a CSS comment block at the top of style.css.
  3. Final Answer:

    /*\nTheme Name: My Theme\n*/ -> Option A
  4. Quick Check:

    Metadata uses CSS comments /* ... */ [OK]
Hint: Metadata must be inside CSS comment block /* ... */ [OK]
Common Mistakes:
  • Using // or # which are not CSS comments
  • Using HTML comments in CSS
  • Placing metadata outside comment block
3. Given this metadata block in style.css, what is the theme's version?
/*
Theme Name: Simple Theme
Author: Jane Doe
Version: 1.2.3
*/
medium
A. Jane Doe
B. 1.2.3
C. Simple Theme
D. style.css

Solution

  1. Step 1: Locate the Version field

    Within the metadata block, the line starting with 'Version:' shows the theme's version number.
  2. Step 2: Read the version value

    The version is '1.2.3' as given after 'Version:'.
  3. Final Answer:

    1.2.3 -> Option B
  4. Quick Check:

    Version field = 1.2.3 [OK]
Hint: Look for 'Version:' line in metadata block [OK]
Common Mistakes:
  • Confusing Author with Version
  • Picking Theme Name as version
  • Ignoring the metadata block format
4. What is wrong with this metadata block in style.css that prevents WordPress from recognizing the theme?
/*
Theme-Name: Cool Theme
Author: John Smith
Version: 2.0
*/
medium
A. The field 'Theme-Name' should be 'Theme Name' without a dash
B. The comment block is missing the closing tag
C. The version number must be numeric only
D. Author name cannot contain spaces

Solution

  1. Step 1: Check metadata field names

    WordPress requires exact field names like 'Theme Name' with a space, not 'Theme-Name'.
  2. Step 2: Verify comment block correctness

    The comment block is properly opened and closed with /* and */.
  3. Final Answer:

    The field 'Theme-Name' should be 'Theme Name' without a dash -> Option A
  4. Quick Check:

    Field names must match exactly [OK]
Hint: Use exact field names like 'Theme Name' with space [OK]
Common Mistakes:
  • Using dashes instead of spaces in field names
  • Leaving comment block unclosed
  • Misunderstanding version format rules
5. You want to create a child theme that inherits styles from its parent. Which metadata field must you add in the child theme's style.css to link it to the parent theme?
hard
A. Inherits: parent-theme-folder-name
B. Parent: parent-theme-name
C. Template: parent-theme-folder-name
D. Depends-On: parent-theme-name

Solution

  1. Step 1: Understand child theme metadata

    To link a child theme to its parent, WordPress uses the 'Template' field with the parent's folder name.
  2. Step 2: Identify correct field name

    The correct metadata field is 'Template', not 'Parent', 'Inherits', or 'Depends-On'.
  3. Final Answer:

    Template: parent-theme-folder-name -> Option C
  4. Quick Check:

    Child theme uses Template field to link parent [OK]
Hint: Use 'Template' field with parent's folder name [OK]
Common Mistakes:
  • Using 'Parent' instead of 'Template'
  • Confusing theme name with folder name
  • Omitting the Template field in child theme