Challenge - 5 Problems
Custom Header & Footer Master
Get all challenges correct to earn this badge!
Test your skills under time pressure!
ā component_behavior
intermediate2:00remaining
What will this WordPress header.php output?
Given this
header.php snippet in a WordPress theme, what HTML will be rendered in the browser?Wordpress
<?php ?><!DOCTYPE html> <html <?php language_attributes(); ?>> <head> <meta charset="<?php bloginfo('charset'); ?>"> <title><?php wp_title('|', true, 'right'); ?></title> <?php wp_head(); ?> </head> <body <?php body_class(); ?>> <header> <h1><?php bloginfo('name'); ?></h1> <nav><?php wp_nav_menu(['theme_location' => 'primary']); ?></nav> </header>
Attempts:
2 left
š” Hint
Look carefully at the functions that add language attributes, charset, and menu.
ā Incorrect
The code uses WordPress functions to add language attributes, charset, title with separator, and the primary menu inside the nav. Option A matches this output including the DOCTYPE and body classes.
ā state_output
intermediate2:00remaining
What is the footer content after this WordPress footer.php runs?
Consider this
footer.php snippet in a WordPress theme. What will be the visible footer content on the page?Wordpress
<?php ?><footer> <p>© <?php echo date('Y'); ?> <?php bloginfo('name'); ?></p> <?php wp_footer(); ?> </footer> </body> </html>
Attempts:
2 left
š” Hint
Remember PHP date('Y') returns the current year.
ā Incorrect
The PHP code outputs the current year dynamically and the site name from bloginfo('name'). wp_footer() adds scripts but does not change visible text. Option D matches the expected output.
š Syntax
advanced2:00remaining
Which option causes a syntax error in a WordPress header.php?
Identify which code snippet will cause a syntax error when used in a WordPress theme's header.php file.
Attempts:
2 left
š” Hint
Check for missing semicolons in PHP statements.
ā Incorrect
Option C is missing a semicolon after the echo statement, causing a syntax error. Options A and D are valid because language_attributes() and bloginfo() echo output by default. Option C is correct syntax.
š§ Debug
advanced2:00remaining
Why does the custom footer not show the menu?
A developer added this code to footer.php to show a menu, but the menu does not appear on the site. What is the most likely cause?
Wordpress
<?php wp_nav_menu(['theme_location' => 'footer']); ?>
Attempts:
2 left
š” Hint
Check if the theme supports the menu location used.
ā Incorrect
If the menu location 'footer' is not registered in the theme's functions.php with register_nav_menus(), wp_nav_menu() will not display anything. The other options are incorrect because wp_nav_menu() can be used anywhere, empty menus show fallback, and CSS classes are optional.
š§ Conceptual
expert2:00remaining
How does WordPress decide which header.php to load?
In a WordPress theme, multiple header files exist:
header.php, header-home.php, and header-special.php. Which function call loads header-special.php?Attempts:
2 left
š” Hint
Check how get_header() uses its parameter to load custom header files.
ā Incorrect
Calling get_header('special') loads header-special.php if it exists. get_header() loads header.php by default. get_header('home') loads header-home.php. Direct include() is not recommended in WordPress themes.