Bird
0
0

What is wrong with this code?

medium📝 Debug Q7 of 15
Wordpress - Custom Post Types and Taxonomies
What is wrong with this code?
register_taxonomy('genre', ['post'], ['hierarchical' => 'yes']);
AThe post types should be a string, not an array
BThe 'hierarchical' value should be a boolean, not a string
CThe taxonomy name 'genre' is invalid
DThe function register_taxonomy() does not accept arrays
Step-by-Step Solution
Solution:
  1. Step 1: Check the 'hierarchical' argument type

    This argument expects a boolean true or false, but 'yes' is a string.
  2. Step 2: Validate correct argument types

    Passing a string instead of boolean can cause unexpected behavior.
  3. Final Answer:

    The 'hierarchical' value should be a boolean, not a string -> Option B
  4. Quick Check:

    Boolean required for hierarchical argument [OK]
Quick Trick: Use true/false, not 'yes'/'no' for booleans [OK]
Common Mistakes:
  • Passing string 'yes' instead of boolean true
  • Thinking post types must be string only
  • Assuming arrays are invalid for arguments

Want More Practice?

15+ quiz questions · All difficulty levels · Free

Free Signup - Practice All Questions
More Wordpress Quizzes