What is the difference between `get_attached_media()` and `get_children()` for retrieving attachment posts?

WordPress Expert Medium

WordPress Expert — Medium

What is the difference between `get_attached_media()` and `get_children()` for retrieving attachment posts?

Key points

  • get_attached_media() filters by MIME type; get_children() retrieves all children
  • get_attached_media() is more specific in its media retrieval
  • get_children() includes non-attachment children as well
  • Understanding the distinction helps in accurately retrieving attachment posts

Ready to go further?

Related questions