Title: Auto-hide Rows based on Date
Last modified: September 1, 2016

---

# Auto-hide Rows based on Date

 *  Resolved [Jen via CDS Support](https://wordpress.org/support/users/cds2016/)
 * (@cds2016)
 * [9 years, 10 months ago](https://wordpress.org/support/topic/auto-hide-rows-based-on-date/)
 * Hello! I would first like to thank TobiasBg for your **amazing** plugin AND support.
   It has saved me so much time on a project I’m working on for a client. You’re
   killing it!
 * My question revolves around auto-filtering via current date. I have one table
   with a historical list of data sorted by descending dates which appear within
   the rows, going as far back as 2010. I need to show the same table across two
   different pages, one page would only **show** the most recent 6 mo. of data, 
   and the other page would **hide** the most recent 6 mo. of data (this is going
   to be an archive page). Eventually, this section will be managed by non-developers
   so I need this to be done automatically. Is this possible? Additional wrench:
   this is a regulated project and I cannot publicly share a dev link. But, I can
   share that I’m already using this in the custom commands box:
 *     ```
       "columnDefs": [ { "orderable": false, "targets": [ 0,6,7,8] } ]
       ```
   
 * _Here’s a little info on my skill set if it helps: I am a designer by trade and
   developer by necessity; expert in CSS/HTML, ok with jquery. Meh with PHP. _
 * THANK YOU!
 * [https://wordpress.org/plugins/tablepress/](https://wordpress.org/plugins/tablepress/)

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

 *  Plugin Author [Tobias Bäthge](https://wordpress.org/support/users/tobiasbg/)
 * (@tobiasbg)
 * [9 years, 10 months ago](https://wordpress.org/support/topic/auto-hide-rows-based-on-date/#post-7616014)
 * Hi,
 * thanks for your post, and sorry for the trouble.
 * Unfortunately, I can’t really think of a directly usable solution here 🙁
    Your
   best bet probably is the approach that is described in [https://wordpress.org/support/topic/show-only-future-dates?replies=14](https://wordpress.org/support/topic/show-only-future-dates?replies=14)
   with that TablePress Row Filter by Date Extension. It might need modifications
   due to that 6 months timeframe.
 * Regards,
    Tobias
 *  Thread Starter [Jen via CDS Support](https://wordpress.org/support/users/cds2016/)
 * (@cds2016)
 * [9 years, 10 months ago](https://wordpress.org/support/topic/auto-hide-rows-based-on-date/#post-7616071)
 * Yes—I came across that thread in my search but moved on as it didn’t seem to 
   mention any way of setting any sort of a date range.
 * I will take your advice and look into modifying the extension you shared. We’ve
   already got 5 of your extensions installed so thanks again for all you’ve done
   with this plugin—I know this date situation is probably a crazy, one-off need.
 * I can probably figure out how to setup a _‘show only dates within a 6-mo range’_
   environment eventually, but do you have any guidance on how to make this work
   for both tables? Where one shows the most recent 6 mo. of data, and the other
   page would hide that data? It’s been years since I’ve gotten down with good ol’
   PHP. Of course, I plan to share any solution I end up with here in the forum,
   just in case anyone in the future has a similar need.
 *  Plugin Author [Tobias Bäthge](https://wordpress.org/support/users/tobiasbg/)
 * (@tobiasbg)
 * [9 years, 10 months ago](https://wordpress.org/support/topic/auto-hide-rows-based-on-date/#post-7616124)
 * Hi,
 * the “trick” here would be to modify the `_filter_date_is_past()` and _filter_date_is_future()`
   methods as necessary. They are comparing the dates in the table with “today”,
   so you would have to add an offset of 6 months to that comparision.
 * Regards,
    Tobias
 *  Thread Starter [Jen via CDS Support](https://wordpress.org/support/users/cds2016/)
 * (@cds2016)
 * [9 years, 10 months ago](https://wordpress.org/support/topic/auto-hide-rows-based-on-date/#post-7616148)
 * Thanks! It looks like I got it to work by modifying the code as you advised:
 * **line 63:**
 *     ```
       return ( $date_timestamp < strtotime( 'today' ) && $date_timestamp < strtotime( '- 6 months' ) );
       ```
   
 * **line 95:**
 *     ```
       return ( $date_timestamp < strtotime( 'today' ) && $date_timestamp > strtotime( '- 6 months' ) );
       ```
   
 * Please let me know if you think anything about the mods are a bit “hacky” since
   I’m quite rusty at PHP, but so far it looks functional for my client’s needs.
 * Thank you for your help with this, and for a great plugin!
 *  Plugin Author [Tobias Bäthge](https://wordpress.org/support/users/tobiasbg/)
 * (@tobiasbg)
 * [9 years, 10 months ago](https://wordpress.org/support/topic/auto-hide-rows-based-on-date/#post-7616150)
 * Hi,
 * yes, that’s basically what I had in mind 🙂
    Good to hear that you were able 
   to implement this so quickly!
 * In the first line, you could probably even remove the first condition, as it’s
   redundant.
 * Best wishes,
    Tobias
 * P.S.: In case you haven’t, please [rate TablePress](https://wordpress.org/support/view/plugin-reviews/tablepress)
   here in the plugin directory. Thanks!
 *  Thread Starter [Jen via CDS Support](https://wordpress.org/support/users/cds2016/)
 * (@cds2016)
 * [9 years, 10 months ago](https://wordpress.org/support/topic/auto-hide-rows-based-on-date/#post-7616153)
 * Well, I was only able to get it up and running so quickly due to your awesome
   support! I do plan on tossing a decent donation your way as I foresee using your
   plugin quite a lot in the future—thanks for your awesome contribution and time
   dedication to the WP community.
 *  Plugin Author [Tobias Bäthge](https://wordpress.org/support/users/tobiasbg/)
 * (@tobiasbg)
 * [9 years, 10 months ago](https://wordpress.org/support/topic/auto-hide-rows-based-on-date/#post-7616160)
 * Hi,
 * thank you so much for your donation, I really appreciate it!
    All the best for
   your project!
 * Best wishes,
    Tobias

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

The topic ‘Auto-hide Rows based on Date’ 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

 * [date](https://wordpress.org/support/topic-tag/date/)
 * [filtering](https://wordpress.org/support/topic-tag/filtering/)
 * [Hide rows](https://wordpress.org/support/topic-tag/hide-rows/)

 * 7 replies
 * 2 participants
 * Last reply from: [Tobias Bäthge](https://wordpress.org/support/users/tobiasbg/)
 * Last activity: [9 years, 10 months ago](https://wordpress.org/support/topic/auto-hide-rows-based-on-date/#post-7616160)
 * Status: resolved