Complete the code to define the theme's style sheet URI in functions.php.
<?php
function mytheme_enqueue_styles() {
wp_enqueue_style('mytheme-style', get_template_directory_uri() . '/[1]');
}
add_action('wp_enqueue_scripts', 'mytheme_enqueue_styles');The main stylesheet file for a WordPress theme is style.css. Using get_template_directory_uri() . '/style.css' correctly points to the style sheet.
Complete the code to register a navigation menu in functions.php.
<?php
function mytheme_setup() {
register_nav_menus(array(
'primary' => '[1]'
));
}
add_action('after_setup_theme', 'mytheme_setup');The label for the menu location can be any string, but 'Primary Menu' is a common descriptive name for the main navigation.
Fix the error in the code to properly load the theme's text domain for translations.
<?php
function mytheme_setup() {
load_theme_textdomain('[1]', get_template_directory() . '/languages');
}
add_action('after_setup_theme', 'mytheme_setup');The text domain must match the theme folder name or the one defined in style.css. Usually, it is lowercase and matches the theme slug, like mytheme.
Fill both blanks to create a basic index.php template that loads the header and footer.
<?php get_[1](); ?> <h1>Welcome to my theme</h1> <?php get_[2](); ?>
get_sidebar() instead of get_footer().The get_header() function loads the header template, and get_footer() loads the footer template. These are essential parts of a WordPress theme's page structure.
Fill all three blanks to create a basic loop in index.php that displays post titles.
<?php if (have_posts()) : while (have_posts()) : the_[1](); ?><h2><?php the_[2](); ?></h2><?php endwhile; else : ?><p>No posts found.</p><?php endif; get_[3]();
the_post() incorrectly spelled.the_content() instead of the_title().The loop uses the_post() to set up post data, the_title() to display the post title, and get_footer() to load the footer template.