Import data from a spreadsheet (.csv file format) and display it in a sortable HTML table.
CSV to SortTable is great for anyone who wants to display information from a spreadsheet on a WordPress website. This plugin can be used to display product catalogs, inventory lists, leaderboards or anything else that can be stored in a CSV file.
Insert a sortable table into any page or post using this shortcode:
The result will be a beautiful, semantically-correct HTML table populated with the contents of your file.
This plugin automatically does a few things for you, all of which can be disabled:
To disable any of these features, use the
disable shortcode attribute:
[csv src=http://example.com/myfile.csv disable=css]
[csv src=http://example.com/myfile.csv disable=icons,images]
[csv src=http://example.com/myfile.csv disable=all]
The first example would disable only the plugin CSS; the second would disable both the file-type icons and image links; and the third would disable all optional features. Disable any combination using a comma-separated list (no spaces!).
Want to give your table a unique ID? Use the
id shortcode attribute:
[csv src=http://example.com/myfile.csv id=my_data_table]
The above example would give the
<table> element an
id attribute of
This can be done by assigning a column number to the
group shortcode attribute:
[csv src=http://example.com/myfile.csv group=3]
The result would be a special class assigned to each table row based on the value of the third column.
By default, table data is sorted alphabetically. If you want to sort columns numerically or as dates, or disable sorting on certain columns, use the following shortcode attributes:
[csv src=http://example.com/myfile.csv number=2]
[csv src=http://example.com/myfile.csv date=3]
[csv src=http://example.com/myfile.csv unsortable=4,5,6]
The values can be a single column number, or multiple column numbers in a comma-separated list (no spaces!).
src value is a relative path (beginning with a forward slash), the plugin will refer to the "Site address (URL)" defined in
WP-Admin > Settings > General:
The above example would refer to
You may want to manipulate the CSV data after it is imported, but before the HTML table is rendered. To do so, use this filter:
Here are some code examples of how to use the data array filter: