0
0
Wordpressframework~20 mins

Header and footer customization in Wordpress - Practice Problems & Coding Challenges

Choose your learning style9 modes available
Challenge - 5 Problems
šŸŽ–ļø
Header & Footer Mastery
Get all challenges correct to earn this badge!
Test your skills under time pressure!
ā“ component_behavior
intermediate
2:00remaining
What is the output of this WordPress header customization code?
Consider this code snippet added to a WordPress theme's header.php file. What will the visitor see in the browser's header area?
Wordpress
<?php
function custom_header_text() {
  echo '<h1>Welcome to My Site</h1>';
}
add_action('wp_head', 'custom_header_text');
?>
AThe text 'Welcome to My Site' appears at the top of the page body as a visible heading.
BThe text 'Welcome to My Site' appears inside the HTML <head> section, not visible on the page body.
CNothing appears because the function is hooked to the wrong action and never runs.
DA PHP error occurs because the function is missing a return statement.
Attempts:
2 left
šŸ’” Hint
Think about where the 'wp_head' action runs in the HTML structure.
ā“ state_output
intermediate
2:00remaining
What will be the footer output after this WordPress code runs?
This code is added to a theme's functions.php to customize the footer. What will the visitor see at the bottom of the page?
Wordpress
<?php
function add_custom_footer() {
  echo '<p>Ā© 2024 My Company</p>';
}
add_action('wp_footer', 'add_custom_footer');
?>
ANothing appears because the hook 'wp_footer' is not called by default in themes.
BThe text appears inside the HTML <head> section, not visible on the page body.
CThe text 'Ā© 2024 My Company' appears at the bottom of the page body.
DA fatal error occurs because the function is not returning a value.
Attempts:
2 left
šŸ’” Hint
Remember where the 'wp_footer' action is triggered in WordPress themes.
šŸ“ Syntax
advanced
2:00remaining
Which option correctly registers a custom header menu in WordPress?
You want to add a new menu location called 'Header Menu' to your theme. Which code snippet correctly registers it?
Aregister_nav_menu('header-menu', 'Header Menu');
Bregister_nav_menus('header-menu', 'Header Menu');
Cregister_nav_menu(array('header-menu' => 'Header Menu'));
Dregister_nav_menus(array('header-menu' => 'Header Menu'));
Attempts:
2 left
šŸ’” Hint
Check the function name and parameter types carefully.
šŸ”§ Debug
advanced
2:00remaining
Why does this footer customization code cause a blank page?
This code is added to functions.php. Why does the site show a blank page after adding it?
Wordpress
<?php
add_action('wp_footer', 'custom_footer');
function custom_footer() {
  echo '<p>Footer Text</p>';
}
?>
AMissing semicolon after the echo statement causes a PHP parse error.
BThe function name 'custom_footer' conflicts with a WordPress core function.
CThe hook 'wp_footer' is misspelled and never runs.
DEchoing HTML inside functions.php is not allowed and causes errors.
Attempts:
2 left
šŸ’” Hint
Look carefully at the syntax inside the function.
🧠 Conceptual
expert
3:00remaining
Which statement best explains how to safely customize a WordPress theme's header and footer?
You want to add custom content to the header and footer without losing changes when the theme updates. What is the best approach?
AUse a child theme to override <code>header.php</code> and <code>footer.php</code> and add your customizations there.
BDirectly edit the theme's <code>header.php</code> and <code>footer.php</code> files to add your content.
CAdd your custom header and footer content inside the WordPress admin Appearance > Customize > Header/Footer sections.
DInstall a plugin that disables the theme's header and footer and replaces them with your own.
Attempts:
2 left
šŸ’” Hint
Think about how to keep your changes safe from theme updates.