Bird
0
0

Given this functions.php snippet in a child theme, what will happen?

medium📝 component behavior Q13 of 15
Wordpress - Theme Structure and Basics
Given this functions.php snippet in a child theme, what will happen?
<?php
function child_theme_styles() {
  wp_enqueue_style('parent-style', get_template_directory_uri() . '/style.css');
  wp_enqueue_style('child-style', get_stylesheet_directory_uri() . '/style.css', array('parent-style'));
}
add_action('wp_enqueue_scripts', 'child_theme_styles');
?>
AStyles cause a fatal error and site breaks
BOnly parent styles load, child styles ignored
COnly child styles load, parent styles ignored
DBoth parent and child styles load correctly, child overrides parent
Step-by-Step Solution
Solution:
  1. Step 1: Analyze enqueue order

    The parent style is enqueued first, then the child style with parent as dependency.
  2. Step 2: Understand effect on styles

    This ensures parent styles load first, then child styles override them if needed.
  3. Final Answer:

    Both parent and child styles load correctly, child overrides parent -> Option D
  4. Quick Check:

    Proper enqueue order = parent then child [OK]
Quick Trick: Child style depends on parent style in enqueue [OK]
Common Mistakes:
  • Forgetting to enqueue parent style
  • Loading child style before parent
  • Not setting dependency array

Want More Practice?

15+ quiz questions · All difficulty levels · Free

Free Signup - Practice All Questions
More Wordpress Quizzes