Challenge - 5 Problems
Custom Taxonomy Master
Get all challenges correct to earn this badge!
Test your skills under time pressure!
❓ component_behavior
intermediate2:00remaining
What is the output of this code when registering a taxonomy?
Consider this WordPress code snippet that registers a custom taxonomy. What will be the slug used for the taxonomy in the URL?
function create_movie_genre_taxonomy() {
register_taxonomy(
'genre',
'movie',
array(
'label' => 'Genres',
'rewrite' => array('slug' => 'film-genre'),
'hierarchical' => true
)
);
}
add_action('init', 'create_movie_genre_taxonomy');Wordpress
function create_movie_genre_taxonomy() {
register_taxonomy(
'genre',
'movie',
array(
'label' => 'Genres',
'rewrite' => array('slug' => 'film-genre'),
'hierarchical' => true
)
);
}
add_action('init', 'create_movie_genre_taxonomy');Attempts:
2 left
💡 Hint
Look at the 'rewrite' argument in the register_taxonomy function.
✗ Incorrect
The 'rewrite' argument with 'slug' => 'film-genre' sets the URL slug for the taxonomy to 'film-genre'. Without this, it would default to the taxonomy name 'genre'.
❓ state_output
intermediate2:00remaining
What is the value of 'hierarchical' for this taxonomy?
Given this code snippet, what is the effect of the 'hierarchical' argument on the taxonomy behavior?
register_taxonomy('topic', 'post', array('hierarchical' => false));Wordpress
register_taxonomy('topic', 'post', array('hierarchical' => false));
Attempts:
2 left
💡 Hint
Think about how WordPress treats hierarchical true vs false taxonomies.
✗ Incorrect
When 'hierarchical' is false, the taxonomy behaves like tags, meaning no parent-child structure is allowed.
📝 Syntax
advanced2:00remaining
Which option will cause a syntax error when registering a taxonomy?
Identify which code snippet will cause a syntax error in WordPress when registering a custom taxonomy.
Attempts:
2 left
💡 Hint
Look carefully at the commas separating array elements.
✗ Incorrect
Option A is missing a comma between 'Genres' and 'hierarchical' keys, causing a syntax error.
🔧 Debug
advanced2:00remaining
Why does this taxonomy not appear in the admin menu?
This code registers a taxonomy but it does not show up in the WordPress admin menu. What is the reason?
register_taxonomy('genre', 'post', array('show_ui' => false));Wordpress
register_taxonomy('genre', 'post', array('show_ui' => false));
Attempts:
2 left
💡 Hint
Check the 'show_ui' argument in register_taxonomy.
✗ Incorrect
'show_ui' controls whether the taxonomy appears in the admin interface. Setting it to false hides it.
🧠 Conceptual
expert2:00remaining
Which statement about custom taxonomies is TRUE?
Select the correct statement about custom taxonomies in WordPress.
Attempts:
2 left
💡 Hint
Think about flexibility of taxonomies and REST API integration.
✗ Incorrect
Custom taxonomies can be linked to multiple post types by passing an array of post types to register_taxonomy.