Welcome to the Treehouse Community

Want to collaborate on code errors? Have bugs you need feedback on? Looking for an extra set of eyes on your latest project? Get support with fellow developers, designers, and programmers of all backgrounds and skill levels here with the Treehouse Community!

Looking to learn something new?

Treehouse offers a seven day free trial for new students. Get access to thousands of hours of content and join thousands of Treehouse students and alumni in the community today.

Start your free trial

WordPress WordPress Hooks - Actions and Filters Filter Functions in WordPress The apply_filters Function

Martin Gibson
Martin Gibson
6,581 Points

Why do filters exist?

After watching this video on filters it got me thinking about the purpose of filters. Like the purpose of a filter is to provide a way for someone to edit something, whether it be in a plugin, theme or Wordpress itself. But why not instead of documenting filters, communicating filters and expecting users to know how to use a filter, why not just create a settings page? This seems far more practical. Am I missing something?

1 Answer

Shane Oliver
Shane Oliver
19,977 Points

A filter is a the middle point between the browser and the server. When you call information from the server or pass to the server you may need to filter this data for various reasons. For example, requesting an API requires filtering before displaying the results in a meaningful way to users.