0
0
Wordpressframework~20 mins

Child themes and overrides in Wordpress - Practice Problems & Coding Challenges

Choose your learning style9 modes available
Challenge - 5 Problems
🎖️
Child Theme Master
Get all challenges correct to earn this badge!
Test your skills under time pressure!
component_behavior
intermediate
2:00remaining
What happens when a child theme overrides a parent theme template file?
In WordPress, if a child theme contains a template file with the same name as one in the parent theme, which template will WordPress use when rendering the page?
AWordPress uses the template file from the parent theme, ignoring the child theme's file.
BWordPress uses the template file from the child theme, overriding the parent theme's file.
CWordPress throws an error because of duplicate template files.
DWordPress merges both template files and uses the combined result.
Attempts:
2 left
💡 Hint
Think about how child themes are designed to customize parent themes.
📝 Syntax
intermediate
2:00remaining
Which code snippet correctly enqueues a child theme stylesheet in WordPress?
You want to enqueue the child theme's stylesheet properly in WordPress. Which of the following code snippets is correct?
Aadd_action('wp_enqueue_scripts', function() { wp_enqueue_style('child-style', get_stylesheet_directory_uri() . '/style.css'); });
Badd_action('wp_enqueue_scripts', function() { wp_enqueue_style('child-style', get_template_directory_uri() . '/style.css'); });
Cadd_action('init', function() { wp_enqueue_style('child-style', get_stylesheet_directory_uri() . '/style.css'); });
Dadd_action('wp_head', function() { wp_enqueue_style('child-style', get_stylesheet_directory_uri() . '/style.css'); });
Attempts:
2 left
💡 Hint
Remember the correct hook and function to get the child theme directory URI.
🔧 Debug
advanced
2:00remaining
Why does the child theme's CSS not apply despite enqueueing the stylesheet?
A developer enqueues the child theme's stylesheet using get_stylesheet_directory_uri() but notices the styles are not applied. What is the most likely cause?
AThe child theme's stylesheet path is incorrect because <code>get_template_directory_uri()</code> should be used instead.
BThe child theme's stylesheet is enqueued correctly but the parent theme's stylesheet is missing.
CThe child theme's stylesheet is enqueued without a version number, causing caching issues.
DThe parent theme's stylesheet is enqueued after the child theme's, overriding child styles.
Attempts:
2 left
💡 Hint
Think about the order stylesheets load and which styles take precedence.
🧠 Conceptual
advanced
2:00remaining
What is the purpose of the Template header in a child theme's style.css?
In a WordPress child theme's style.css file, what does the Template header specify?
AIt defines the parent theme's directory name that the child theme inherits from.
BIt specifies the CSS selector to apply styles to the parent theme.
CIt declares the child theme's version number for cache control.
DIt sets the template engine used by WordPress to render the theme.
Attempts:
2 left
💡 Hint
Think about how WordPress knows which theme is the parent.
state_output
expert
3:00remaining
What is the output of this child theme functions.php code?
Consider this functions.php code in a child theme. What will be the output when the site loads?

add_action('wp_enqueue_scripts', function() {
  wp_enqueue_style('parent-style', get_template_directory_uri() . '/style.css');
  wp_enqueue_style('child-style', get_stylesheet_directory_uri() . '/style.css', ['parent-style']);
});

add_action('wp_head', function() {
  echo '<!-- Child theme loaded -->';
});
Wordpress
add_action('wp_enqueue_scripts', function() {
  wp_enqueue_style('parent-style', get_template_directory_uri() . '/style.css');
  wp_enqueue_style('child-style', get_stylesheet_directory_uri() . '/style.css', ['parent-style']);
});

add_action('wp_head', function() {
  echo '<!-- Child theme loaded -->';
});
AThe child stylesheet loads before the parent, causing style conflicts, and the comment appears twice.
BOnly the parent stylesheet loads, and the HTML comment does not appear.
CThe parent and child stylesheets load in correct order, and the HTML comment <!-- Child theme loaded --> appears in the page head.
DA fatal error occurs because of missing function parameters.
Attempts:
2 left
💡 Hint
Check the order of enqueued styles and where the comment is echoed.