While working on project an interesting problem arose, needing to pass an additional parameter to a WordPress filter. Normally filters only allow for a set number of parameters, but the particular filter needed an additional parameter that could be passed when calling the filter.
The problem was being able to run a WP_Query for a set number of days passed. This is normally accomplished with a simple filter that is applied to posts_where. The problem is the number of days would be variable, since it was being set via a widget option. To get around this using OOP and create a new class that stores the variable and that will be passed when calling the filter. While the example below is a specific solution to the problem above it can be adapted for pretty well any filter that needs another parameter that can be set when calling the filter.
Continue reading
![By Florian Hirzinger – www.fh-ap.com (Own work (Florian Hirzinger)) [CC-BY-SA-3.0 or GFDL], via Wikimedia Commons](http://static.clark-technet.com/wp-content/uploads/2013/04/800px-CERN_Server-300x199.jpg)
