A custom taxonomy is a way to group content in WordPress beyond the default categories and tags. It helps organize posts or custom post types with your own labels.
Click to reveal answer
beginner
Which WordPress function is used to register a custom taxonomy?
The function register_taxonomy() is used to create a new custom taxonomy in WordPress.
Click to reveal answer
intermediate
What are the two main types of taxonomies in WordPress?
The two main types are hierarchical (like categories) and non-hierarchical (like tags). Hierarchical taxonomies allow parent-child relationships, non-hierarchical do not.
Click to reveal answer
intermediate
How do you link a custom taxonomy to a custom post type?
When registering the taxonomy with register_taxonomy(), you specify the post type(s) it applies to in the second argument as a string or array.
Click to reveal answer
beginner
Why use custom taxonomies instead of just categories or tags?
Custom taxonomies let you organize content in ways that fit your site’s needs better. They provide more meaningful grouping and improve content discovery.
Click to reveal answer
Which function registers a custom taxonomy in WordPress?
Acreate_taxonomy()
Badd_taxonomy()
Cregister_taxonomy()
Dnew_taxonomy()
✗ Incorrect
The correct function to register a custom taxonomy is register_taxonomy().
What type of taxonomy allows parent and child terms?
ATagged
BNon-hierarchical
CFlat
DHierarchical
✗ Incorrect
Hierarchical taxonomies allow parent-child relationships between terms.
How do you assign a custom taxonomy to a post type?
ABy listing the post type in register_taxonomy()
BBy editing the post type file
CBy creating a new post type
DBy adding a meta box
✗ Incorrect
You assign a taxonomy to a post type by specifying the post type(s) in the register_taxonomy() function.
Which of these is NOT a default WordPress taxonomy?
ACategory
BGenre
CTag
DPost Format
✗ Incorrect
Genre is not a default taxonomy; it is often created as a custom taxonomy.
Why create a custom taxonomy?
ATo organize content in a way that fits your site
BTo replace categories and tags
CTo delete posts
DTo change the site theme
✗ Incorrect
Custom taxonomies help organize content better according to your site’s needs.
Explain what a custom taxonomy is and how it differs from default WordPress taxonomies.
Think about grouping content in new ways.
You got /3 concepts.
Describe the steps to register a custom taxonomy and link it to a custom post type.
Focus on the function and its arguments.
You got /3 concepts.
Practice
(1/5)
1. What is the main purpose of creating a custom taxonomy in WordPress?
easy
A. To increase website loading speed
B. To change the website's theme colors
C. To add new user roles
D. To organize content in a way that fits your website's needs
Solution
Step 1: Understand what taxonomy means in WordPress
Taxonomies group content like categories or tags to organize posts.
Step 2: Identify the purpose of custom taxonomies
Custom taxonomies let you create your own groups to better fit your content.
Final Answer:
To organize content in a way that fits your website's needs -> Option D
Quick Check:
Custom taxonomy = organize content [OK]
Hint: Custom taxonomies organize content, not change design or speed [OK]
Common Mistakes:
Confusing taxonomies with themes or plugins
Thinking taxonomies affect site speed
Mixing taxonomies with user roles
2. Which of the following is the correct way to register a custom taxonomy called genre for posts in WordPress?
easy
A. register_taxonomy('genre', 'post', array('hierarchical' => true));
B. register_taxonomy('genre', 'posts', array('hierarchical' => true));
C. register_taxonomy('genre', array('post'), 'hierarchical' => true);
D. register_taxonomy('genre', 'post', 'hierarchical' => true);
Solution
Step 1: Check the function signature of register_taxonomy()
The function requires taxonomy name, object type(s) as string or array, and an array of arguments.
Step 2: Verify correct parameter types and syntax
register_taxonomy('genre', 'post', array('hierarchical' => true)); uses 'post' as string and an array for arguments correctly.
Final Answer:
register_taxonomy('genre', 'post', array('hierarchical' => true)); -> Option A
Quick Check:
Correct syntax uses array for args and string for post type [OK]
Hint: Use array() for args and string or array for post types [OK]
C. The third argument should be an array, not a key-value pair directly
D. The function name is incorrect
Solution
Step 1: Check the function parameters
register_taxonomy() expects the third argument as an array of arguments.
Step 2: Identify the error in argument format
The code passes 'hierarchical' => true directly, not inside an array, causing syntax error.
Final Answer:
The third argument should be an array, not a key-value pair directly -> Option C
Quick Check:
Args must be in array() [OK]
Hint: Always wrap arguments in array() for register_taxonomy [OK]
Common Mistakes:
Passing arguments without array()
Using plural taxonomy names incorrectly
Wrong function name like register_taxonomies
5. You want to create a custom taxonomy called location that behaves like tags (non-hierarchical) and attach it to both post and event post types. Which code snippet correctly achieves this?
hard
A. register_taxonomy('location', array('post', 'event'), array('hierarchical' => false));
C. register_taxonomy('location', array('post', 'event'), array('hierarchical' => true));
D. register_taxonomy('location', array('post', 'event'), array('hierarchical' => true, 'tags' => true));
Solution
Step 1: Understand hierarchical argument for tags
Tags are non-hierarchical, so 'hierarchical' must be false.
Step 2: Attach taxonomy to multiple post types
Pass an array of post types ['post', 'event'] as second argument.
Step 3: Check options for correct syntax and behavior
register_taxonomy('location', array('post', 'event'), array('hierarchical' => false)); correctly sets 'hierarchical' => false and attaches to both post types in one call.
Final Answer:
register_taxonomy('location', array('post', 'event'), array('hierarchical' => false)); -> Option A