Bird
0
0

How can you create a custom page template that supports both manual assignment and automatic use for pages with a specific slug?

hard📝 Application Q9 of 15
Wordpress - Custom Theme Development
How can you create a custom page template that supports both manual assignment and automatic use for pages with a specific slug?
AUse only a template header in a generic template file
BCreate page-portfolio.php with a template header comment
CCreate a plugin to assign templates dynamically
DAdd a filter to override template selection
Step-by-Step Solution
Solution:
  1. Step 1: Combine template hierarchy and manual assignment

    Adding a template header to page-portfolio.php allows manual assignment and automatic slug matching.
  2. Step 2: Confirm template header presence

    The header makes it selectable in the editor, while the file name matches slug automatically.
  3. Final Answer:

    Create page-portfolio.php with a template header comment -> Option B
  4. Quick Check:

    File name + header = manual and automatic use [OK]
Quick Trick: Add header to page-{slug}.php for both uses [OK]
Common Mistakes:
  • Ignoring template header in slug files
  • Relying only on plugins for assignment
  • Not using correct file naming

Want More Practice?

15+ quiz questions · All difficulty levels · Free

Free Signup - Practice All Questions
More Wordpress Quizzes