Bird
0
0

You want to organize your theme's template parts inside a folder named template-parts. How do you correctly load template-parts/header-main.php?

hard📝 Application Q8 of 15
Wordpress - Custom Theme Development
You want to organize your theme's template parts inside a folder named template-parts. How do you correctly load template-parts/header-main.php?
Aget_template_part('header-main');
Bget_template_part('header', 'main');
Cget_template_part('template-parts/header', 'main');
Dinclude('template-parts/header-main.php');
Step-by-Step Solution
Solution:
  1. Step 1: Understand folder usage in get_template_part()

    To load files inside subfolders, include the folder path in the slug parameter.
  2. Step 2: Apply to the example

    Use 'template-parts/header' as slug and 'main' as name to load 'template-parts/header-main.php'.
  3. Final Answer:

    get_template_part('template-parts/header', 'main'); -> Option C
  4. Quick Check:

    Include folder in slug to load nested template parts [OK]
Quick Trick: Add folder path in slug to load nested template parts [OK]
Common Mistakes:
  • Ignoring folder path
  • Using wrong function
  • Passing combined slug-name string

Want More Practice?

15+ quiz questions · All difficulty levels · Free

Free Signup - Practice All Questions
More Wordpress Quizzes