How to change the background color of Grouped Columns

Date: May 26, 2022


If you have created non-server-side tables (tables linked to Excel, CSV, Google Spreadsheet, XML, PHP, JSON, or MySQL query-based tables with "Server-side processing" turned off) you will be able to select a column that would be used for row grouping. More info about this feature can be found here.

In order to make those grouped rows stand out, you may want to add some background color to them. Conditional formatting and column colors won't work since the column is being converted into rows.

You can, however, add custom CSS in the “Customize” section above the table:

.wpDataTable td.group{
    background: red;
}
.wpDataTable td.group:hover{
    background: blue;
}

Also, you can apply this only to certain table IDs. For example:

.wpDataTableID-1 td.group{
    background: red;
}
.wpDataTableID-1 td.group:hover{
    background: blue;
}

Just make sure to change “1” with the ID of your table.

Hope this helps!