Choose the best description of what the functions.php file does in a WordPress theme.
Think about where you add custom code to change how WordPress works without editing core files.
The functions.php file is used to add custom PHP code, functions, and hooks that modify or extend WordPress features for the theme. It does not control layout (that is templates) or styles (that is CSS files).
Consider you add a function named custom_login_message() in your theme's functions.php file, but a plugin also defines a function with the same name. What will happen when WordPress runs?
Think about how PHP handles two functions with the same name loaded in the same request.
In PHP, declaring two functions with the same name causes a fatal error. WordPress does not automatically resolve this conflict, so the site will break unless the conflict is fixed.
Choose the correct code to register a new menu location called 'Footer Menu' in functions.php.
Look for the function that registers multiple menu locations using an array.
The correct way to add a menu location is using register_nav_menus() with an array of slug => description pairs. register_nav_menu() registers only one menu but requires a different syntax.
At what point in the WordPress loading process is the functions.php file of the active theme loaded?
Think about when theme functions need to be available for hooks and templates.
The functions.php file is loaded early after WordPress core files load, so its functions and hooks are available throughout the page load process, including templates.
Given this code added to functions.php:
add_action('init', 'my_custom_function');
function my_custom_function() {
echo 'Hello World!';
}Why might this cause a white screen (blank page) when loading the site?
Consider when headers are sent and what happens if output is sent too early.
Outputting text during the 'init' hook sends output before headers, which can cause PHP errors or prevent headers from being sent properly, resulting in a white screen.