Title: add_filter not working
Last modified: August 22, 2016

---

# add_filter not working

 *  [sant527](https://wordpress.org/support/users/sant527/)
 * (@sant527)
 * [11 years, 10 months ago](https://wordpress.org/support/topic/add_filter-not-working/)
 * Added the below apply_filters in a file in my theme
 *     ```
       $videos_query = apply_filter('mars_main_widget_args',$videos_query,$this->id);
       $wp_query = new WP_Query( $videos_query );
       ```
   
 * In the themes function file i have
 *     ```
       if( !function_exists( 'mars_widget_post_ids' ) ){
           /**
            * @param array $query
            * @param string $widget_id
            */
           function mars_widget_post_ids( $query, $widget_id ) {
               if( $widget_id == 'mars-mainvideo-widgets-5' ){
                   $query['post__in'] = array( 1,4,5,6 );
               }
               return $query;
           }
           add_filter( 'mars_main_widget_args' , 'mars_widget_post_ids',100,2);
       }
       ```
   
 * The filter is not being applied any mistake

Viewing 2 replies - 1 through 2 (of 2 total)

 *  Moderator [bcworkz](https://wordpress.org/support/users/bcworkz/)
 * (@bcworkz)
 * [11 years, 10 months ago](https://wordpress.org/support/topic/add_filter-not-working/#post-5333471)
 * Why do you need to go through a filter? Why not just call `mars_widget_post_ids()`
   directly?
 * If you really do need the filter, there may be an issue where the filter is applied
   before the callback is added. It’s hard to say without more context. `$this->
   id` looks a little suspicious without more context too. Is this in a class declaration?
   Or there just may be a typical bug where a variable doesn’t have the value you
   think it does. The usual debugging techniques will track something like that 
   down.
 *  [vankaa](https://wordpress.org/support/users/vankaa/)
 * (@vankaa)
 * [11 years, 10 months ago](https://wordpress.org/support/topic/add_filter-not-working/#post-5333512)
 * You have a typo for “apply_filters” declaration, you wrote it “apply_filter”,
   could this be your issue?

Viewing 2 replies - 1 through 2 (of 2 total)

The topic ‘add_filter not working’ is closed to new replies.

## Tags

 * [filter](https://wordpress.org/support/topic-tag/filter/)

 * In: [Hacks](https://wordpress.org/support/forum/plugins-and-hacks/hacks/)
 * 2 replies
 * 3 participants
 * Last reply from: [vankaa](https://wordpress.org/support/users/vankaa/)
 * Last activity: [11 years, 10 months ago](https://wordpress.org/support/topic/add_filter-not-working/#post-5333512)
 * Status: not resolved

## Topics

### Topics with no replies

### Non-support topics

### Resolved topics

### Unresolved topics

### All topics
