Title: Using Filter addon with only one column
Last modified: August 21, 2016

---

# Using Filter addon with only one column

 *  Resolved [Brian](https://wordpress.org/support/users/bwold/)
 * (@bwold)
 * [12 years, 1 month ago](https://wordpress.org/support/topic/using-filter-addon-with-only-one-column/)
 * Tobias, great work on this plugin. I hope I’m not missing an obvious answer here.
   In any event, thanks in advance.
 * We’re pulling in a member list in CSV that comes from a separate source, and 
   we only want to display members who haven’t opted out of the list. In the source
   CSV, the column is “OPT_OUT” and the values are 1 (yes, opt out) and 0 (okay 
   to display). Therefore, we want to only display those members where the OPT_OUT
   column equals 0.
 * So I’m working with the Table Row Filters premium plugin, but I need to only 
   search in that one column.
 * I didn’t see it in the documentation, but filters also includes a filter_columns
   parameter. After many attempts, I finally figured out the syntax.
 * `[table id=1 filter="0" filter_columns="35" /]`
 * Seems obvious now, but having hidden a number of other columns from our source
   CSV, it took a while to realize that the column number is counted based on the
   total columns in the source, not just the visible ones. And I’m embarrassed to
   say how many attempts I made using OPT_OUT.
 * So, we’re good, except the filter parameter doesn’t seem to like a value of zero.
   If I set the above to filter=”1″, I get the 35 members who have opted out, but
   set it to filter=”0″ and I get all records — ones and zeroes.
 * Am I missing something?
 * [https://wordpress.org/plugins/tablepress/](https://wordpress.org/plugins/tablepress/)

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

 *  Thread Starter [Brian](https://wordpress.org/support/users/bwold/)
 * (@bwold)
 * [12 years, 1 month ago](https://wordpress.org/support/topic/using-filter-addon-with-only-one-column/#post-4723876)
 * By the way, not in the documentation that I could see, but these are the parameters
   the addon uses:
 * > filter [the search string, required]
   >  filter_full_cell_match [defaults to false]
   > filter_case_sensitive [defaults to false] filter_columns [defaults to all, 
   > or a column number, or numbers (e.g. 1,3,15)]
 *  Plugin Author [Tobias Bäthge](https://wordpress.org/support/users/tobiasbg/)
 * (@tobiasbg)
 * [12 years, 1 month ago](https://wordpress.org/support/topic/using-filter-addon-with-only-one-column/#post-4723878)
 * Hi,
 * thanks for your post, and sorry for the trouble.
 * Ah, that’s a tricky one 🙂 Nice find!
 * The PHP code for the extension uses the PHP `empty()` function (see [http://php.net/empty](http://php.net/empty))
   to check if the `filter` attribute was set with a not-empty value. (If it was,
   there’s nothing for the filter to do, so it can bail early.)
    Unfortunately, 
   the `empty()` function also recognizes the `"0"` string as empty — that’s however
   exactly the filter parameter that you want.
 * Fortunately, fixing this is easy: Just replace the line
 *     ```
       if ( empty( $render_options['filter'] ) )
       ```
   
 * in the `filter_rows` function with
 *     ```
       if ( '' == $render_options['filter'] )
       ```
   
 * Regards,
    Tobias
 *  Thread Starter [Brian](https://wordpress.org/support/users/bwold/)
 * (@bwold)
 * [12 years, 1 month ago](https://wordpress.org/support/topic/using-filter-addon-with-only-one-column/#post-4723881)
 * Okay, I’m so not a developer, and I get itchy hacking code. Apologies in advance
   if I’ve broken any PHP rules, but the edit below seems to work. Please advise
   if I’ve missed something:
 * Edit to wp-content/plugins/tablepress-row-filter/tablepress-row-filter.php, Line
   98 (I added the second check for not zero):
 * `if ( empty( $render_options['filter'] ) && ( $render_options['filter'] ) !=='
   0' )`
 * Again, love this product!
 *  Plugin Author [Tobias Bäthge](https://wordpress.org/support/users/tobiasbg/)
 * (@tobiasbg)
 * [12 years, 1 month ago](https://wordpress.org/support/topic/using-filter-addon-with-only-one-column/#post-4723882)
 * Hi,
 * that idea will also work, but it’s slightly more complicated.
    You can actually
   remove a pair of `(` and `)` if you want:
 *     ```
       if ( empty( $render_options['filter'] ) && $render_options['filter'] !== '0' )
       ```
   
 * You can either use that or use the shorter version that I posted above.
 * Regards,
    Tobias

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

The topic ‘Using Filter addon with only one column’ 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/)

 * 4 replies
 * 2 participants
 * Last reply from: [Tobias Bäthge](https://wordpress.org/support/users/tobiasbg/)
 * Last activity: [12 years, 1 month ago](https://wordpress.org/support/topic/using-filter-addon-with-only-one-column/#post-4723882)
 * Status: resolved