Given this index.php file in a new WordPress theme folder, what will the browser display when visiting the homepage?
<?php // index.php get_header(); ?> <h1>Welcome to my theme!</h1> <?php get_footer(); ?>
Think about what get_header() and get_footer() do in WordPress themes.
The get_header() function loads the header.php file, and get_footer() loads footer.php. So the page shows header content, then the heading, then footer content.
Choose the correct code snippet to enqueue a stylesheet named style.css in a WordPress theme.
Remember to use wp_enqueue_style and the right hook for loading stylesheets.
Option D correctly uses wp_enqueue_style with get_stylesheet_uri() to load the main stylesheet and hooks into wp_enqueue_scripts.
Consider this code inside a theme template file. What will it output if there are 3 posts?
<?php if (have_posts()) : while (have_posts()) : the_post(); the_title('<h2>', '</h2>'); endwhile; else : echo '<p>No posts found.</p>'; endif; ?>
Think about how the WordPress Loop works to display posts.
The loop runs once per post. For 3 posts, it outputs 3 <h2> elements with each post's title.
Given this code in functions.php, why does the stylesheet not appear on the site?
function load_styles() {
wp_enqueue_style('main-style', get_template_directory_uri() . '/style.css');
}
add_action('init', 'load_styles');Check the recommended hook for enqueuing styles in WordPress.
The 'init' hook runs too early for enqueuing styles. The correct hook is 'wp_enqueue_scripts'.
functions.php file in a WordPress theme from scratch?Choose the best description of what functions.php does in a custom WordPress theme.
Think about how WordPress themes add functionality beyond templates.
The functions.php file is loaded by WordPress to add features, register menus, enqueue assets, and customize behavior, similar to a plugin but theme-specific.