Title: row_filter / Filter on variable value
Last modified: July 11, 2020

---

# row_filter / Filter on variable value

 *  Resolved [glorisol](https://wordpress.org/support/users/glorisol/)
 * (@glorisol)
 * [5 years, 10 months ago](https://wordpress.org/support/topic/row_filter-filter-on-variable-value/)
 * I am using tablepress for the website of my cycling club to show the (GPS) clubrides
   schedule.
    See: [https://tourclubduiven.nl/toerkalender/](https://tourclubduiven.nl/toerkalender/)
 * Every ride has the month (e.g “2020-07” for July 2020) in the first column.
    
   Using the row-filter extension I can simply use the ‘filter=”2020-07″‘ phrase
   to filter just the rides scheduled in July 2020.
 * Now I want to make this filtering dynamic, based on a global variable (e.g. “
   $current_month” that I want to set in the page header or footer) so that when
   the page opens the user only sees the rows that match the value in the variable.
 * Plus the user should be able to change the filter as he/she likes (using the 
   selection boxes from the column filter extension)
 * Is there any way to accomplish this?
    -  This topic was modified 5 years, 10 months ago by [glorisol](https://wordpress.org/support/users/glorisol/).
    -  This topic was modified 5 years, 10 months ago by [glorisol](https://wordpress.org/support/users/glorisol/).
    -  This topic was modified 5 years, 10 months ago by [glorisol](https://wordpress.org/support/users/glorisol/).

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

 *  Plugin Author [Tobias Bäthge](https://wordpress.org/support/users/tobiasbg/)
 * (@tobiasbg)
 * [5 years, 10 months ago](https://wordpress.org/support/topic/row_filter-filter-on-variable-value/#post-13111137)
 * Hi,
 * thanks for your question, and sorry for the trouble.
 * Setting this filter term from a variable is possible by using a custom Shortcode
   wrapper. For some inspiration on how this works, please see [https://tablepress.org/extensions/shortcode-filter-get-parameter/](https://tablepress.org/extensions/shortcode-filter-get-parameter/)
 * The drawback of this filter mechanism is that it’s not changeable “live” on the
   page (with JavaScript code). You might there want to use a custom JavaScript 
   solution that simply changes the selection from the ColumnFilterWidgets dropdown
   based on a variable.
 * Regards,
    Tobias
 *  Thread Starter [glorisol](https://wordpress.org/support/users/glorisol/)
 * (@glorisol)
 * [5 years, 10 months ago](https://wordpress.org/support/topic/row_filter-filter-on-variable-value/#post-13117780)
 * mm, but then would it be feasible to set the initial filtering value of the ColumnFilterWidgets
   dropdown to “current_month”?
    Then the user dan allways change that filter value
   to whatever to see another selection of the data in the table.
 *  Plugin Author [Tobias Bäthge](https://wordpress.org/support/users/tobiasbg/)
 * (@tobiasbg)
 * [5 years, 10 months ago](https://wordpress.org/support/topic/row_filter-filter-on-variable-value/#post-13118494)
 * Hi,
 * yes, this would be possible, but you would need custom JavaScript code for it.
 * Regards,
    Tobias
 *  Thread Starter [glorisol](https://wordpress.org/support/users/glorisol/)
 * (@glorisol)
 * [5 years, 10 months ago](https://wordpress.org/support/topic/row_filter-filter-on-variable-value/#post-13118896)
 * You would be very helpful if you could help me with a basic function that ‘sets’
   the filter value for the first column/dropdown defined in ColumnFilterWidgets.
 * I looked a the plugin code and this seems too complex for me to do on my own (
   being able to copy/adapt javascript and php code)
    -  This reply was modified 5 years, 10 months ago by [glorisol](https://wordpress.org/support/users/glorisol/).
 *  Plugin Author [Tobias Bäthge](https://wordpress.org/support/users/tobiasbg/)
 * (@tobiasbg)
 * [5 years, 10 months ago](https://wordpress.org/support/topic/row_filter-filter-on-variable-value/#post-13119947)
 * Hi,
 * unfortunately, I don’t have this code readily available. Your best chance probably
   is some JavaScript code, maybe using jQuery. As I’m not the developer of the 
   JS code of the ColumnFilterWidgets, I also don’t know where this adjustment would
   have to be made, sorry. It would probably even be the best to make this code 
   run after the ColumnFilterWidgets have been added to the page.
 * Regards,
    Tobias
 *  [turbopress](https://wordpress.org/support/users/turbopress/)
 * (@turbopress)
 * [5 years, 10 months ago](https://wordpress.org/support/topic/row_filter-filter-on-variable-value/#post-13198485)
 * This is amazing, thank you!
 *  Plugin Author [Tobias Bäthge](https://wordpress.org/support/users/tobiasbg/)
 * (@tobiasbg)
 * [5 years, 10 months ago](https://wordpress.org/support/topic/row_filter-filter-on-variable-value/#post-13198993)
 * Hi,
 * no problem, you are very welcome! 🙂 Good to hear that this helped!
 * Best wishes,
    Tobias
 * P.S.: In case you haven’t, please [rate TablePress](https://wordpress.org/support/plugin/tablepress/reviews/#new-post)
   here in the plugin directory. Thanks!

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

The topic ‘row_filter / Filter on variable value’ 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/)

 * 7 replies
 * 3 participants
 * Last reply from: [Tobias Bäthge](https://wordpress.org/support/users/tobiasbg/)
 * Last activity: [5 years, 10 months ago](https://wordpress.org/support/topic/row_filter-filter-on-variable-value/#post-13198993)
 * Status: resolved