Bird
0
0

Identify the error in this code snippet for updating a taxonomy term name:

medium📝 Debug Q14 of 15
Wordpress - Custom Post Types and Taxonomies
Identify the error in this code snippet for updating a taxonomy term name:
 wp_update_term(123, 'category', ['name' => 'New Name']); 
AThe taxonomy slug 'category' is incorrect for terms
BNo error; this code correctly updates the term name
CTerm ID must be a string, not an integer
DThe third parameter should be a string, not an array
Step-by-Step Solution
Solution:
  1. Step 1: Check wp_update_term() parameters

    The function takes term ID (integer), taxonomy slug (string), and an array of args to update.
  2. Step 2: Verify usage correctness

    Using term ID 123, taxonomy 'category', and array with 'name' key is correct syntax and usage.
  3. Final Answer:

    No error; this code correctly updates the term name -> Option B
  4. Quick Check:

    wp_update_term() usage = correct [OK]
Quick Trick: wp_update_term() needs term ID, taxonomy, and args array [OK]
Common Mistakes:
  • Passing term ID as string instead of integer
  • Using wrong parameter types
  • Confusing taxonomy slug with term name

Want More Practice?

15+ quiz questions · All difficulty levels · Free

Free Signup - Practice All Questions
More Wordpress Quizzes