Practice - 5 Tasks
Answer the questions below
1fill in blank
easyComplete the code to set the permalink structure to use post name in WordPress.
Wordpress
add_action('init', function() { global $wp_rewrite; $wp_rewrite->set_permalink_structure('[1]'); });
Drag options to blanks, or click blank then click option'
Attempts:
3 left
💡 Hint
Common Mistakes
Using date-based structures when the question asks for post name.
Using query string style URLs instead of pretty permalinks.
✗ Incorrect
The '/%postname%/' structure uses the post's slug in the URL, which is common for clean permalinks.
2fill in blank
mediumComplete the code to flush rewrite rules after changing permalink structure.
Wordpress
add_action('init', function() { global $wp_rewrite; $wp_rewrite->set_permalink_structure('/%postname%/'); [1](); });
Drag options to blanks, or click blank then click option'
Attempts:
3 left
💡 Hint
Common Mistakes
Not flushing rewrite rules after changing permalink structure.
Using unrelated functions like update_option.
✗ Incorrect
flush_rewrite_rules() refreshes WordPress's permalink rules so changes take effect.
3fill in blank
hardFix the error in the code to correctly set a custom permalink structure with category and post name.
Wordpress
add_action('init', function() { global $wp_rewrite; $wp_rewrite->set_permalink_structure('[1]'); flush_rewrite_rules(); });
Drag options to blanks, or click blank then click option'
Attempts:
3 left
💡 Hint
Common Mistakes
Swapping the order of category and post name tags.
Using author or year tags when not asked.
✗ Incorrect
The correct order is category first, then post name for this permalink structure.
4fill in blank
hardFill both blanks to create a permalink structure with year and post ID.
Wordpress
add_action('init', function() { global $wp_rewrite; $wp_rewrite->set_permalink_structure('[1][2]'); flush_rewrite_rules(); });
Drag options to blanks, or click blank then click option'
Attempts:
3 left
💡 Hint
Common Mistakes
Using postname instead of post ID.
Putting monthnum instead of post ID.
✗ Incorrect
Combining year and post ID creates URLs like /2024/123/.
5fill in blank
hardFill all three blanks to create a permalink structure with category, year, and post name.
Wordpress
add_action('init', function() { global $wp_rewrite; $wp_rewrite->set_permalink_structure('[1][2][3]'); flush_rewrite_rules(); });
Drag options to blanks, or click blank then click option'
Attempts:
3 left
💡 Hint
Common Mistakes
Including author tag when not asked.
Wrong order of tags.
✗ Incorrect
This structure creates URLs like /category/2024/post-name/.