• Resolved wagsinbburg

    (@wagsinbburg)


    Is there a way to filter the data that is displayed on the page based on a field in the DB? I want to display the record only if the date and time field are before the current data and time of the server. Hope that makes since, this plugin is very close to what I need just can’t find anything to point me in the direction I need. Thanks!

    https://wordpress.org/plugins/tablepress/

Viewing 5 replies - 1 through 5 (of 5 total)
  • Plugin Author TobiasBg

    (@tobiasbg)

    Hi,

    thanks for your post, and sorry for the trouble.

    I don’t have a directly usable solution, but this TablePress Extension should be a good starting point:
    http://tablepress.org/download/extension/tablepress-row-filter-date.zip
    After installing and activating that, you can use a Shortcode like

    [table id=123 filter_date="past" filter_date_columns="3" /]

    which will result in only those rows being displayed where the date in column 3 is in the past.

    Regards,
    Tobias

    Thread Starter wagsinbburg

    (@wagsinbburg)

    Great I will give it a try, I need to filter on the Time as well, can I just add filter_time=”past” filter_time_column=”4″?

    Do I need to configure the tables columns to be a specific date \ time format?

    Plugin Author TobiasBg

    (@tobiasbg)

    Hi,

    no, sorry, the Extension does not directly work for time, only for dates. You will need to extend the code of the Extension to also cover the time with some new PHP code.

    The allowed date formats are those English date formats that PHP understands, see http://php.net/manual/en/datetime.formats.date.php
    I would suggest to go with the standard “mm/dd/yyyy”, if possible, as that’s probably the most reliable.

    Regards,
    Tobias

    Thread Starter wagsinbburg

    (@wagsinbburg)

    Thanks again for the response. I need the time to work in the filter as well, I tried it with the “2014-08-13T09:55:00+00:00” as the field and that didnt work as you suggested so I guess I go back to the drawing board. Thanks

    Plugin Author TobiasBg

    (@tobiasbg)

    Hi,

    that format should work, likely only regarding the date part, while it will ignore the time (unless you extend the Extension).
    Then, you might also need to turn off table output caching, by extending your table’s Shortcode to

    [table id=123 cache_table_output=false /]

    Regards,
    Tobias

Viewing 5 replies - 1 through 5 (of 5 total)
  • The topic ‘Display Data Based on Date and Time Field in the DB’ is closed to new replies.