How to make Fixed Columns For WordPress Datatables (Sticky Columns)

From wpDataTables 5.6, there’s a way to fix the table’s columns to the right and/or left of the screen, when the user scrolls horizontally through a large table on a page. This way, the selected number of columns will always be visible so that the user can see relevant information in scrollable columns, whilst keeping some columns with important information fixed.

In order to activate Fixed Columns, you need to access the “Advanced” tab above your table and enable the Fixed Columns checkbox:


The Left columns numbers and the Right columns numbers represent the number of columns that are going to be fixed on the left and the right side of the table (respectively). In the example above, 2 initial columns on the left will be fixed, and the last (1) column will be fixed on the right while the columns in between will be scrollable horizontally.

The table shown below represents multiple hotels with a bit more data where your site visitors may want to browse through the table but still be looking at the first few columns in order to see what leisure these hotels have to offer and the last column, so they can see the price for each of those hotels.

Please note that this is a dummy table, and does not represent real data.

Fixed Headers can be combined with Fixed Columns, so your tables can have both a fixed header and fixed columns in order to provide a better viewing experience for your site visitors.

An example of this combination can be seen in the table below.