0
0
Wordpressframework~10 mins

Taxonomy term management 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 get all terms of a taxonomy.

Wordpress
<?php
$terms = get_terms(array('taxonomy' => '[1]'));
?>
Drag options to blanks, or click blank then click option'
Apage
Bpost
Cuser
Dcategory
Attempts:
3 left
💡 Hint
Common Mistakes
Using 'post' or 'page' instead of taxonomy name.
2fill in blank
medium

Complete the code to create a new term in a taxonomy.

Wordpress
<?php
wp_insert_term('New Term', '[1]');
?>
Drag options to blanks, or click blank then click option'
Acategory
Btag
Cauthor
Dcomment
Attempts:
3 left
💡 Hint
Common Mistakes
Using non-taxonomy names like 'author' or 'comment'.
3fill in blank
hard

Fix the error in the code to get terms with no empty results.

Wordpress
<?php
$terms = get_terms(array('taxonomy' => 'category', 'hide_empty' => [1]));
?>
Drag options to blanks, or click blank then click option'
A0
Bfalse
Cnull
Dtrue
Attempts:
3 left
💡 Hint
Common Mistakes
Using 'true' hides empty terms.
Using 0 may not work as expected.
4fill in blank
hard

Fill both blanks to update a term's name and slug.

Wordpress
<?php
wp_update_term([1], 'category', array('name' => 'Updated Name', 'slug' => '[2]'));
?>
Drag options to blanks, or click blank then click option'
A15
B20
Cupdated-name
Dnew-slug
Attempts:
3 left
💡 Hint
Common Mistakes
Using slug as a number.
Using term ID as a string slug.
5fill in blank
hard

Fill all three blanks to register a custom taxonomy.

Wordpress
<?php
register_taxonomy('[1]', '[2]', array('label' => '[3]'));
?>
Drag options to blanks, or click blank then click option'
Agenre
Bpost
CGenres
Dcategory
Attempts:
3 left
💡 Hint
Common Mistakes
Using 'category' as taxonomy slug for custom taxonomy.
Mixing label and slug.