Bird
0
0

You want to display a gallery of images from the Media Library filtered by a custom taxonomy. Which approach is best?

hard📝 Application Q8 of 15
Wordpress - Content Management
You want to display a gallery of images from the Media Library filtered by a custom taxonomy. Which approach is best?
AUse WP_Query with 'attachment' post type and taxonomy filter
BManually upload images and hardcode URLs
CUse get_posts() without taxonomy filtering
DUse wp_get_attachment_url() for all media files
Step-by-Step Solution
Solution:
  1. Step 1: Identify how to query media with taxonomy

    WP_Query supports querying attachments with taxonomy filters.
  2. Step 2: Evaluate other options

    Hardcoding URLs or ignoring taxonomy won't filter correctly.
  3. Final Answer:

    Use WP_Query with 'attachment' post type and taxonomy filter -> Option A
  4. Quick Check:

    Query attachments with taxonomy = B [OK]
Quick Trick: WP_Query can filter media by taxonomy [OK]
Common Mistakes:
  • Ignoring taxonomy filters
  • Hardcoding media URLs
  • Using functions that don't filter

Want More Practice?

15+ quiz questions · All difficulty levels · Free

Free Signup - Practice All Questions
More Wordpress Quizzes