You must be defining your callback function inside a function that is reused by the widget system-- my guess is inside the `widget` method. Define the callback outside the widget itself, and only apply (`apply_filter`) inside the widget. In other words, add your callback as class method, and add it something like this: add_filter('posts_where', array($this,'filter_where')); You should be able to remove it with a similar syntax. Without seeing your code in context that is the best I've got.