0
0
Wordpressframework~20 mins

Template hierarchy in Wordpress - Practice Problems & Coding Challenges

Choose your learning style9 modes available
Challenge - 5 Problems
🎖️
WordPress Template Master
Get all challenges correct to earn this badge!
Test your skills under time pressure!
🧠 Conceptual
intermediate
2:00remaining
Understanding WordPress Template Hierarchy Order
In WordPress, when displaying a single post of a custom post type named 'book', which template file will WordPress try to load first according to the template hierarchy?
Asingle.php
Bsingular.php
Csingle-book.php
Dindex.php
Attempts:
2 left
💡 Hint
Think about the most specific template file for the custom post type.
component_behavior
intermediate
2:00remaining
Template Selection for Category Archive
If you visit a category archive page for a category with slug 'news' and ID 7, which template file will WordPress use if all these files exist in the theme: category-news.php, category-7.php, category.php, archive.php?
Acategory-7.php
Bcategory-news.php
Ccategory.php
Darchive.php
Attempts:
2 left
💡 Hint
WordPress prefers templates with category ID over slug if both exist.
📝 Syntax
advanced
2:00remaining
Identify the Correct Template File Name
Which of the following is the correct template file name to target the author archive page for an author with the nicename 'johnsmith'?
Aauthor_johnsmith.php
Bauthor-johnsmith.php
Cauthor-john_smith.php
Dauthorjohnsmith.php
Attempts:
2 left
💡 Hint
WordPress uses hyphens to separate 'author' and the nicename.
🔧 Debug
advanced
2:00remaining
Why is my custom taxonomy template not loading?
You created a custom taxonomy called 'genre'. You added a template file named taxonomy-genre.php in your theme, but when visiting a genre archive page, WordPress loads archive.php instead. What is the most likely reason?
AWordPress never uses taxonomy-{taxonomy}.php templates
BThe template file name must be taxonomy-{taxonomy}-{term}.php to work
CThe taxonomy slug is incorrect; it should be taxonomy-genre-{term}.php
DThe taxonomy-genre.php file is not recognized because the taxonomy is registered with a different slug
Attempts:
2 left
💡 Hint
Check the exact slug used when registering the taxonomy.
state_output
expert
2:00remaining
Template Hierarchy Output for Nested Pages
Given a WordPress page with slug 'about' and a child page with slug 'team', which template file will WordPress use to display the child page if these files exist: page-team.php, page-about.php, page.php, singular.php?
Apage-team.php
Bpage-about.php
Cpage.php
Dsingular.php
Attempts:
2 left
💡 Hint
WordPress looks for the most specific page template by slug.