Title: Importing Table Removes HTML5 data- Attributes
Last modified: October 21, 2021

---

# Importing Table Removes HTML5 data- Attributes

 *  Resolved [lipskas](https://wordpress.org/support/users/lipskas/)
 * (@lipskas)
 * [4 years, 7 months ago](https://wordpress.org/support/topic/importing-table-removes-html5-data-attributes/)
 * Using the latest version of plugin. Previously I used JSON format to import tables,
   but I need extra DataTables functionality (support for HTML5 **data-order** attribute
   for specified cells), so I switched to pure HTML.
 * Problem: when table is imported, all HTML5 attributes are removed. Let’s say 
   HTML file looks like this:
 *     ```
       <table>
           <tr><td data-order='1'>Monday</td><tr>
           <tr><td data-order='2'>Tuesday</td><tr>
           <tr><td data-order='3'>Wednesday</td><tr>
           <tr><td data-order='4'>Thursday</td><tr>
           <tr><td data-order='5'>Friday</td><tr>
           <tr><td data-order='6'>Saturday</td><tr>
           <tr><td data-order='7'>Sunday</td><tr>
       </table>
       ```
   
 * After import it becomes:
 *     ```
       <table>
           <tr><td>Monday</td><tr>
           <tr><td>Tuesday</td><tr>
           <tr><td>Wednesday</td><tr>
           <tr><td>Thursday</td><tr>
           <tr><td>Friday</td><tr>
           <tr><td>Saturday</td><tr>
           <tr><td>Sunday</td><tr>
       </table>
       ```
   
 * Which causes problems because sorting for such column works not as user expects.
   How can I preserve HTML5 attributes during HTML import (or how can I add them
   to JSON file)?
 * P.S. I also noticed that plugin uses very old version of DataTables. Could you
   update it, please?

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

 *  Plugin Author [Tobias Bäthge](https://wordpress.org/support/users/tobiasbg/)
 * (@tobiasbg)
 * [4 years, 7 months ago](https://wordpress.org/support/topic/importing-table-removes-html5-data-attributes/#post-14991897)
 * Hi,
 * thanks for your post, and sorry for the trouble.
 * Unfortunately, I’ll have to disappoint you here. The problem is not so much the
   import of these attributes, but that TablePress does not have a way to save them
   in its table format – it can only save the cell content.
 * As an alternative, I recommend to add these attributes dynamically, e.g. via 
   the `tablepress_cell_tag_attributes` filter hook (see [https://github.com/TobiasBg/TablePress/blob/master/classes/class-render.php#L716](https://github.com/TobiasBg/TablePress/blob/master/classes/class-render.php#L716)).
   Or, you could try adding this information for DataTables via a “Custom Command”
   on the table’s “Edit” screen.
 * Regarding the DataTables version: TablePress currently uses 1.10.25, which is
   the latest version in the 1.10 branch (and not “very old” on my opinion 🙂 ).
   Switching to the current 1.11.3 is planned for the next major update of TablePress,
   as I also have to take into account potential issues with backwards-compatibility.
 * Regards,
    Tobias
 *  Thread Starter [lipskas](https://wordpress.org/support/users/lipskas/)
 * (@lipskas)
 * [4 years, 7 months ago](https://wordpress.org/support/topic/importing-table-removes-html5-data-attributes/#post-15010584)
 * Thank you for the response. I checked the `tablepress_cell_tag_attributes`, but
   I’m not sure if it suits my needs. If I understand right, I need to utilize this
   in functions.php? Will it work if I know nothing about table? I mean every time
   the table is imported, it contains a different number of rows and data is slightly
   different. Also, I need to add `data-` attributes to more columns (not just weekdays),
   doesn’t it mean a lot of programming is involved here?
 *  Plugin Author [Tobias Bäthge](https://wordpress.org/support/users/tobiasbg/)
 * (@tobiasbg)
 * [4 years, 7 months ago](https://wordpress.org/support/topic/importing-table-removes-html5-data-attributes/#post-15011551)
 * Hi,
 * yes, depending on the structure of your tables, this could mean quite a bit of
   custom programming.
 * Maybe, developing a custom sorting algorithm with type detection for DataTables(
   see [https://datatables.net/plug-ins/sorting/](https://datatables.net/plug-ins/sorting/))
   could be an option that. You could maybe use [https://tablepress.org/extensions/datatables-sorting-plugins/](https://tablepress.org/extensions/datatables-sorting-plugins/)
   as a foundation for that.
 * Regards,
    Tobias

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

The topic ‘Importing Table Removes HTML5 data- Attributes’ 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/)

 * 3 replies
 * 2 participants
 * Last reply from: [Tobias Bäthge](https://wordpress.org/support/users/tobiasbg/)
 * Last activity: [4 years, 7 months ago](https://wordpress.org/support/topic/importing-table-removes-html5-data-attributes/#post-15011551)
 * Status: resolved