0
0
Wordpressframework~10 mins

Permalink structure in Wordpress - Interactive Code Practice

Choose your learning style9 modes available
Practice - 5 Tasks
Answer the questions below
1fill in blank
easy

Complete 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'
A/%postname%/
B/%year%/%monthnum%/%day%/
C/archives/%post_id%
D/?p=%post_id%
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.
2fill in blank
medium

Complete 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'
Aregister_post_type
Bupdate_option
Cflush_rewrite_rules
Dadd_rewrite_rule
Attempts:
3 left
💡 Hint
Common Mistakes
Not flushing rewrite rules after changing permalink structure.
Using unrelated functions like update_option.
3fill in blank
hard

Fix 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'
A/%postname%/%category%/
B/%category%/%postname%/
C/%author%/%postname%/
D/%year%/%postname%/
Attempts:
3 left
💡 Hint
Common Mistakes
Swapping the order of category and post name tags.
Using author or year tags when not asked.
4fill in blank
hard

Fill 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'
A/%year%/
B/%post_id%/
C/%postname%/
D/%monthnum%/
Attempts:
3 left
💡 Hint
Common Mistakes
Using postname instead of post ID.
Putting monthnum instead of post ID.
5fill in blank
hard

Fill 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'
A/%category%/
B/%year%/
C/%postname%/
D/%author%/
Attempts:
3 left
💡 Hint
Common Mistakes
Including author tag when not asked.
Wrong order of tags.