0
0
Wordpressframework~20 mins

Custom taxonomies in Wordpress - Practice Problems & Coding Challenges

Choose your learning style9 modes available
Challenge - 5 Problems
🎖️
Custom Taxonomy Master
Get all challenges correct to earn this badge!
Test your skills under time pressure!
component_behavior
intermediate
2: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');
AThe taxonomy URL slug will be 'Genres'.
BThe taxonomy URL slug will be 'genre'.
CThe taxonomy URL slug will be 'movie'.
DThe taxonomy URL slug will be 'film-genre'.
Attempts:
2 left
💡 Hint
Look at the 'rewrite' argument in the register_taxonomy function.
state_output
intermediate
2: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));
AThe taxonomy behaves like categories with parent-child relationships.
BThe taxonomy will not be visible in the admin dashboard.
CThe taxonomy behaves like tags without parent-child relationships.
DThe taxonomy will cause a fatal error.
Attempts:
2 left
💡 Hint
Think about how WordPress treats hierarchical true vs false taxonomies.
📝 Syntax
advanced
2: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.
Aregister_taxonomy('genre', 'book', array('label' => 'Genres' 'hierarchical' => true));
Bregister_taxonomy('genre', 'book', array('label' => 'Genres', 'hierarchical' => true));
Cregister_taxonomy('genre', 'book', array('label' => 'Genres', 'hierarchical' => false));
Dregister_taxonomy('genre', 'book', array('label' => 'Genres', 'hierarchical' => true, 'rewrite' => array('slug' => 'genre')));
Attempts:
2 left
💡 Hint
Look carefully at the commas separating array elements.
🔧 Debug
advanced
2: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));
ABecause the taxonomy name 'genre' is reserved and cannot be shown.
BBecause 'show_ui' is set to false, the taxonomy UI is hidden in admin.
CBecause 'show_ui' is missing, the taxonomy defaults to hidden.
DBecause 'show_in_menu' is false by default, it hides the taxonomy.
Attempts:
2 left
💡 Hint
Check the 'show_ui' argument in register_taxonomy.
🧠 Conceptual
expert
2:00remaining
Which statement about custom taxonomies is TRUE?
Select the correct statement about custom taxonomies in WordPress.
ACustom taxonomies can be associated with multiple post types.
BCustom taxonomies must be registered before the 'init' hook runs.
CCustom taxonomies can only be hierarchical like categories.
DCustom taxonomies automatically appear in REST API without extra settings.
Attempts:
2 left
💡 Hint
Think about flexibility of taxonomies and REST API integration.