Posts table sort options
Posts Table Pro comes with two options for sorting the table when it first loads. Once the table has loaded, users can click on a column heading to sort by that column.
Sort by
The Sort by option controls which column should be used for sorting the table when it is first displayed. It defaults to date, which is the date the post or page was published.
You can order by any column in the table, or by any of the following keywords (whether or not they are included in your table):
- ID – sort by post ID
- Title – sort by post title
- WordPress menu order – sort by the ‘order’ option (as listed in your site's primary menu)
- Date – sort by the publish date of the post/page (note: see here to sort by custom field date columns)
- Name – sort by post ‘slug’
- Modified – sort by last modified date
- Author – sort by author name
- Comment count – sort by number of comments
- Random – random order
For lazy loaded tables, you can only sort by the keywords listed above. This is because the sorting is handled by the server when the products are retrieved from the database.
If you are not using the lazy load option, then you can also sort by any other text-based column present in the table. E.g. sort_by="content"
.
Using the table builder

You can easily choose how to sort your posts using the 'Sort by' option in the table builder.
Using a shortcode
You can set the sort order directly in the [posts_table]
 or [posts_table_template id=""]
shortcode. To do this, use the sort_by
shortcode option followed by one of the following:
id
– sort by post IDtitle
– sort by post titlemenu_order
 – sort by the ‘order’ option (as listed in your site's primary menu)date
– sort by the publish date of the post/page (note: see here to sort by custom field date columns)name
 – sort by post ‘slug’modified
 – sort by last modified dateauthor
– sort by author namecomment_count
– sort by number of commentsrand
 – random order
Sort using keyword: [posts_table columns="title,content" sort_by="menu_order"]
Sort using content column in table: [posts_table sort_by="content"]
Sort using custom field column in table: [posts_table sort_by="cf:event"]
Sort order
This controls the direction to use for sorting by when the table is first displayed. By default, descending order is used for date-based sorting, and ascending is used for everything else.
You can set the sort order by selecting 'Ascending' or 'Descending' in the table builder, or directly in a shortcode by using the sort_by
option with either asc
or des
. For example:
[posts_table columns="title,content" sort_by="date" sort_order="asc"]
Can I sort by multiple columns?
No, this is not currently possible. The table can only be sorted by a single column.
Can I sort the table by number?
If you’re using custom fields or taxonomies to store numbers instead of text, then you may wish to sort the table in number order. The only way to sort by number is to create a "Number" custom field using the plugin Advanced Custom Fields and disable lazy load.
Otherwise, the table is sorted alphabetically rather than numerically. This applies to all text-based columns including custom fields and taxonomies.
The only other way to enable the table to be sorted numerically number is to add the numbers in a format that will make sense when ordered alphabetically. For example:
- If you add numbers in the format 1, 2, 3, 4, 5, 6, 7, 8, 9, 10 and 11, then they will be sorted in the following order – 1, 10, 11, 2, 3, 4, etc. This does not look correct.
- If you’re sorting by a custom field containing numbers 01, 02, 03, 04, 05, 06, 07, 08, 09, 10 and 11, then they will be sorted correctly both alphabetically and numerically.