1. Home
  2. Posts Table Pro
  3. Posts Table Pro Options

Posts table sort options

Posts Table Pro comes with 2 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 sets which column should be used for sorting the table by when it is first displayed. 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
  • 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
  • rand – random order

In addition, if you are not using the lazy load option, you can sort by any other text-based column present in the table. E.g. sort_by="content".

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.


Sort using keyword:  [posts_table columns="title,content" sort_by="menu_order"]

Sort using content column in table:  [posts_table columns="image,title,content,author" sort_by="content"]

Sort using custom field column in table:  [posts_table columns="image,title,excerpt,cf:event" sort_by="cf:event"]

Sort order

The direction to use for sorting by when the table is first displayed. Can be either asc for ascending order or desc for descending order.

Defaults to desc for date-based sorting, and asc for everything else, but you can override using this option. For example, if you wanted to alphabetize the table by listing items in alphabetical order, then the default will be correct.


[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?

You can only sort a column numerically if you are using a "Number" custom field created using the plugin Advanced Custom Fields and lazy load should be off. Otherwise, the table is sorted alphabetically rather than numerically. This applies to all text-based columns including custom fields and taxonomies.

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. There is no option for this unless you are using Advanced Custom Fields, but you can achieve this by adding 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.

Related Articles

If searching the knowledge base hasn't answered your question, please contact support.