Practice - 5 Tasks
Answer the questions below
1fill in blank
easyComplete the code to create a WordPress post with the title 'Hello World'.
Wordpress
<?php wp_insert_post(array('post_title' => '[1]', 'post_content' => 'Welcome to my blog!', 'post_status' => 'publish')); ?>
Drag options to blanks, or click blank then click option'
Attempts:
3 left
💡 Hint
Common Mistakes
Using a page title instead of a post title.
✗ Incorrect
The post_title should be the title of the post, here 'Hello World'.
2fill in blank
mediumComplete the code to create a WordPress page with the title 'About Us'.
Wordpress
<?php wp_insert_post(array('post_title' => '[1]', 'post_content' => 'About our company.', 'post_status' => 'publish', 'post_type' => 'page')); ?>
Drag options to blanks, or click blank then click option'
Attempts:
3 left
💡 Hint
Common Mistakes
Using a post title instead of a page title.
✗ Incorrect
The post_title for the page should be 'About Us'.
3fill in blank
hardFix the error in the code to correctly specify the post type as a page.
Wordpress
<?php wp_insert_post(array('post_title' => 'Services', 'post_content' => 'Our services.', 'post_status' => 'publish', 'post_type' => '[1]')); ?>
Drag options to blanks, or click blank then click option'
Attempts:
3 left
💡 Hint
Common Mistakes
Using 'post' or 'blog' instead of 'page'.
✗ Incorrect
The post_type must be 'page' to create a WordPress page.
4fill in blank
hardFill both blanks to create a post with publish status.
Wordpress
<?php wp_insert_post(array('post_title' => 'News Update', 'post_content' => 'Latest news.', 'post_status' => '[1]', 'post_type' => '[2]')); ?>
Drag options to blanks, or click blank then click option'
Attempts:
3 left
💡 Hint
Common Mistakes
Using 'draft' status or 'page' post_type for a post.
✗ Incorrect
The post should be published with post_status 'publish' and post_type 'post'.
5fill in blank
hardFill all three blanks to create a page with a title, content, and published status.
Wordpress
<?php wp_insert_post(array('post_title' => '[1]', 'post_content' => '[2]', 'post_status' => '[3]', 'post_type' => 'page')); ?>
Drag options to blanks, or click blank then click option'
Attempts:
3 left
💡 Hint
Common Mistakes
Using 'draft' status or wrong content for the page.
✗ Incorrect
The page title is 'Contact Us', content is 'Get in touch with us.', and status is 'publish' to make it live.