Practice - 5 Tasks
Answer the questions below
1fill in blank
easyComplete the code to include a template part named 'header'.
Wordpress
<?php get_[1]('header'); ?>
Drag options to blanks, or click blank then click option'
Attempts:
3 left
💡 Hint
Common Mistakes
Using functions that do not exist like get_template_part_include.
Confusing with functions that load full templates.
✗ Incorrect
The correct function to include a template part in WordPress is get_template_part().
2fill in blank
mediumComplete the code to include a template part named 'content' with a slug 'single'.
Wordpress
<?php get_template_part('content', [1]); ?>
Drag options to blanks, or click blank then click option'
Attempts:
3 left
💡 Hint
Common Mistakes
Using the wrong slug name that does not match the file.
Omitting quotes around the slug string.
✗ Incorrect
The second argument in get_template_part() is the slug, here 'single' to load content-single.php.
3fill in blank
hardFix the error in the code to correctly include the sidebar template part.
Wordpress
<?php get_template_part([1]); ?> Drag options to blanks, or click blank then click option'
Attempts:
3 left
💡 Hint
Common Mistakes
Passing the template part name without quotes causing syntax errors.
Including the '.php' extension which is not needed.
✗ Incorrect
The template part name must be a quoted string without the file extension.
4fill in blank
hardFill both blanks to include a template part named 'footer' with a slug 'custom'.
Wordpress
<?php get_template_part([1], [2]); ?>
Drag options to blanks, or click blank then click option'
Attempts:
3 left
💡 Hint
Common Mistakes
Swapping the order of arguments.
Using incorrect names that do not match template files.
✗ Incorrect
The first argument is the template part name 'footer', the second is the slug 'custom'.
5fill in blank
hardFill all three blanks to include a template part named 'content' with slug 'page' and pass an array of variables.
Wordpress
<?php get_template_part([1], [2], [3]); ?>
Drag options to blanks, or click blank then click option'
Attempts:
3 left
💡 Hint
Common Mistakes
Passing variables as a string instead of an array.
Omitting the third argument when variables are needed.
✗ Incorrect
The first two arguments specify the template part and slug; the third passes variables as an array.