Title: Multiple filters simultaneously
Last modified: August 31, 2016

---

# Multiple filters simultaneously

 *  Resolved [TodayOnly](https://wordpress.org/support/users/todayonly/)
 * (@todayonly)
 * [10 years, 3 months ago](https://wordpress.org/support/topic/multiple-filters-simultaneously/)
 * Hi Tobias,
 * I managed to get my TablePress to filter through /?table_filter=keyword1+keyword2,
   but I am struggling to add additional shortcode filters acting simultaneously.
   Say I’d also like to filter on keyword3 in the column, whilst keeping the keyword1
   +keyword2 filter.
 * I’ve tried searching but coudlnt’d find. However I have understand this would
   be possible thought custom JS code that uses the API. Is that the only solution,
   if so, could you link me to where there´s a explanation of integrating with the
   API?
 * [https://wordpress.org/plugins/tablepress/](https://wordpress.org/plugins/tablepress/)

Viewing 15 replies - 1 through 15 (of 19 total)

1 [2](https://wordpress.org/support/topic/multiple-filters-simultaneously/page/2/?output_format=md)
[→](https://wordpress.org/support/topic/multiple-filters-simultaneously/page/2/?output_format=md)

 *  Plugin Author [Tobias Bäthge](https://wordpress.org/support/users/tobiasbg/)
 * (@tobiasbg)
 * [10 years, 3 months ago](https://wordpress.org/support/topic/multiple-filters-simultaneously/#post-7031232)
 * Hi,
 * thanks for your post, and sorry for the trouble.
 * This filtering mechanism does not use any DataTables functions, so that you won’t
   need to deal with the API.
 * Instead, you should only need some changes in the PHP code of the Shortcode Filter
   from GET parameter Extension.
    There, it might be sufficient to adjust the line
 *     ```
       $attributes['filter'] = $filter_term;
       ```
   
 * to
 *     ```
       if ( ! empty( $attributes['filter'] ) ) {
         $attributes['filter'] .= ' ';
       }
       $attributes['filter'] .= $filter_term;
       ```
   
 * (This would append `keyword1+keyword2`, so that you would filter for
 *     ```
       keyword1 keyword2 keyword3
       ```
   
 * Regards,
    Tobias
 *  Thread Starter [TodayOnly](https://wordpress.org/support/users/todayonly/)
 * (@todayonly)
 * [10 years, 3 months ago](https://wordpress.org/support/topic/multiple-filters-simultaneously/#post-7031528)
 * Hi Tobias,
 * Thank you for the help.
 * I am not exactly what you mean by that the keyword would be appended. Say for
   example that the user clicks a URL filter such as example.com/?table_filter=keyword1
   +keyword2 and then later the user clicks on the same page example.com/?table_filter
   =keyword3, would they all 3 be sorted then?
 *  Plugin Author [Tobias Bäthge](https://wordpress.org/support/users/tobiasbg/)
 * (@tobiasbg)
 * [10 years, 3 months ago](https://wordpress.org/support/topic/multiple-filters-simultaneously/#post-7031532)
 * Hi,
 * sorry, that’s not really going to work like that, I’m afraid. If a user clicks
   the new link, the other filter words would be stripped (unless you dynamically
   create the link).
 * Instead of using the Row Filter Extension (and the Filter from GET parameter 
   Extension), you might therefore want to use the JavaScript filtering that is 
   available via the search field above the table. For that, you could then also
   use the Extension from [https://tablepress.org/extensions/datatables-button-filter/](https://tablepress.org/extensions/datatables-button-filter/)
   to add filtering with buttons.
 * Regards,
    Tobias
 *  Thread Starter [TodayOnly](https://wordpress.org/support/users/todayonly/)
 * (@todayonly)
 * [10 years, 3 months ago](https://wordpress.org/support/topic/multiple-filters-simultaneously/#post-7031533)
 * Hi Tobias,
 * The JavaScript solution filtered very quickly and is to prefer.
 * However, as of now it also ignores if a button has been already been clicked.
   I believe editing some PHP file would make that the filter term from previous
   button-click don’t get stripped, am I mistaken?
 *  Plugin Author [Tobias Bäthge](https://wordpress.org/support/users/tobiasbg/)
 * (@tobiasbg)
 * [10 years, 3 months ago](https://wordpress.org/support/topic/multiple-filters-simultaneously/#post-7031538)
 * Hi,
 * yes, this would require modified JavaScript code in the PHP file.
    Basically,
   the line
 *     ```
       {$name}.search( $( this ).data( 'filterterm' ) ).draw();
       ```
   
 * would need to be extended to read the current filter value from the text field
   first and append the extra one to that.
 * Regards,
    Tobias
 *  Thread Starter [TodayOnly](https://wordpress.org/support/users/todayonly/)
 * (@todayonly)
 * [10 years, 3 months ago](https://wordpress.org/support/topic/multiple-filters-simultaneously/#post-7031555)
 * Hi Tobias,
 * I looked into extending that line, but it’s hard.
 * Do you know someone who previously managed to pull this off?
 *  Plugin Author [Tobias Bäthge](https://wordpress.org/support/users/tobiasbg/)
 * (@tobiasbg)
 * [10 years, 3 months ago](https://wordpress.org/support/topic/multiple-filters-simultaneously/#post-7031556)
 * Hi,
 * no, sorry, I’m not aware of users who have modified this before. Something like
   this should maybe work:
 *     ```
       {$name}.search( $( '#tablepress-{$table_id}_filter input' ).val() + ' ' + $( this ).data( 'filterterm' ) ).draw();
       ```
   
 * Regards,
    Tobias
 *  Thread Starter [TodayOnly](https://wordpress.org/support/users/todayonly/)
 * (@todayonly)
 * [10 years, 3 months ago](https://wordpress.org/support/topic/multiple-filters-simultaneously/#post-7031557)
 * Hi Tobias,
 * Thank you for the help. It worked wonderfully!
 * Now I wonder, what is the query I’d enter in the shortcode to reset filters?
 * `<button class="table-123-filter" data-filterterm="ENTER HERE">Button text</button
   >`
 * Thank you again!
 *  Plugin Author [Tobias Bäthge](https://wordpress.org/support/users/tobiasbg/)
 * (@tobiasbg)
 * [10 years, 3 months ago](https://wordpress.org/support/topic/multiple-filters-simultaneously/#post-7031561)
 * Hi,
 * good to hear that this helped!
 * Resetting is not directly possible with just HTML, but would require even more
   JS, basically a call of the function with an empty string. So, you could try 
   replacing
 *     ```
       $( '#tablepress-{$table_id}_filter input' ).val() + ' ' + $( this ).data( 'filterterm' )
       ```
   
 * with a variable that you set to that value by default, or that you set to an 
   empty string, if a special/custom filter term is passed.
 * Regards,
    Tobias
 *  Thread Starter [TodayOnly](https://wordpress.org/support/users/todayonly/)
 * (@todayonly)
 * [10 years, 3 months ago](https://wordpress.org/support/topic/multiple-filters-simultaneously/#post-7031565)
 * Hi Tobias,
 * I am very thankful for you helping me with this.
 * For this solution, I tried Googling to find a variable that set a default value,
   but couldn’t manage to find one.
 * It is quite essential to remove filters, or the user gets stuck.
 * Could you think of another solution, in case you neither can’t find the Javascript
   variable?
 * You are the best.
 *  Plugin Author [Tobias Bäthge](https://wordpress.org/support/users/tobiasbg/)
 * (@tobiasbg)
 * [10 years, 3 months ago](https://wordpress.org/support/topic/multiple-filters-simultaneously/#post-7031566)
 * Hi,
 * it’s not about “finding” the JavaScript variable, it’s about modifying this JS
   code with one, i.e. you will need custom programming here.
 * Regards,
    Tobias
 *  Thread Starter [TodayOnly](https://wordpress.org/support/users/todayonly/)
 * (@todayonly)
 * [10 years, 3 months ago](https://wordpress.org/support/topic/multiple-filters-simultaneously/#post-7031572)
 * Hi Tobias,
 * Thank you for the insight.
 * I was thinking then, an alternative solution, would be that when clicking at 
   the button again, that filter gets deleted. Do you know a way to do that?
 * Best regards
 *  Plugin Author [Tobias Bäthge](https://wordpress.org/support/users/tobiasbg/)
 * (@tobiasbg)
 * [10 years, 3 months ago](https://wordpress.org/support/topic/multiple-filters-simultaneously/#post-7031573)
 * Hi,
 * that’s exactly what I mean and what that code would achieve 🙂
    It’s just that
   I’m pretty busy at the moment, so that I don’t have time to develop such customizations
   in the frame of the free support that I can offer here in the forums. That’s 
   why I was suggesting that you try implementing this yourself, first.
 * Regards,
    Tobias
 *  Thread Starter [TodayOnly](https://wordpress.org/support/users/todayonly/)
 * (@todayonly)
 * [10 years, 2 months ago](https://wordpress.org/support/topic/multiple-filters-simultaneously/#post-7031608)
 * Hi Tobias,
 * I hired a programmer, and he tried adding various codes such as
    var clear = “”;
   var remove = 0;
 * to insert them as variables in the
    `$( '#tablepress-{$table_id}_filter input').
   val() + ' ' + $( this ).data( 'filterterm' )`
 * However, after 15+ tries we couldn’t make it.
 * I am sure there are many users who would like the filter/remove filter feature.
   When you have time, I am in no hurry, could you please take a look at this?
 * Best regards
 *  Plugin Author [Tobias Bäthge](https://wordpress.org/support/users/tobiasbg/)
 * (@tobiasbg)
 * [10 years, 2 months ago](https://wordpress.org/support/topic/multiple-filters-simultaneously/#post-7031609)
 * Hi,
 * something like this should work:
 *     ```
       var filter_term = '';
       if ( '#reset#' !== $( this ).data( 'filterterm' ) ) {
         filter_term = $( '#tablepress-{$table_id}_filter input' ).val() + ' ' + $( this ).data( 'filterterm' );
       }
       {$name}.search( filter_term ).draw();
       ```
   
 * Then, you could use a button like
 *     ```
       <button class="table-123-filter" data-filterterm="#reset#">Reset</button>
       ```
   
 * to reset the search.
 * Regards,
    Tobias

Viewing 15 replies - 1 through 15 (of 19 total)

1 [2](https://wordpress.org/support/topic/multiple-filters-simultaneously/page/2/?output_format=md)
[→](https://wordpress.org/support/topic/multiple-filters-simultaneously/page/2/?output_format=md)

The topic ‘Multiple filters simultaneously’ is closed to new replies.

 * ![](https://ps.w.org/tablepress/assets/icon.svg?rev=3192944)
 * [TablePress - Tables in WordPress made easy](https://wordpress.org/plugins/tablepress/)
 * [Frequently Asked Questions](https://wordpress.org/plugins/tablepress/#faq)
 * [Support Threads](https://wordpress.org/support/plugin/tablepress/)
 * [Active Topics](https://wordpress.org/support/plugin/tablepress/active/)
 * [Unresolved Topics](https://wordpress.org/support/plugin/tablepress/unresolved/)
 * [Reviews](https://wordpress.org/support/plugin/tablepress/reviews/)

## Tags

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

 * 19 replies
 * 2 participants
 * Last reply from: [Tobias Bäthge](https://wordpress.org/support/users/tobiasbg/)
 * Last activity: [10 years, 2 months ago](https://wordpress.org/support/topic/multiple-filters-simultaneously/page/2/#post-7031613)
 * Status: resolved