1. Home
  2. Documentation
  3. Posts Table Pro
  4. Posts Table Pro Shortcode Options
  5. Displaying dates in Posts Table Pro

Displaying dates in Posts Table Pro

Posts Table Pro includes several options for how dates are displayed and formatted in your tables. For example, you can tell the plugin which columns are dates so that it will sort by date rather than alphabetically.

Date columns

The date_columns option is used to specify which columns in your table should be treated as dates. This is useful if you have custom fields or taxonomies which represent date values, and you want enable sorting for these columns or change the format. This option should contain one or more columns (as a comma-separated list) using the same syntax as the columns option. For example:

[posts_table columns="image,title,cf:my_date,tax:my_custom_tax" date_columns="cf:my_date,tax:my_custom_tax"]

You don’t need to include the date column here, as this is always treated as a date. This is just for additional date columns such as custom fields.

Setting this option will also allow you to set the date format for these columns using date_format option.

Date format

The date_format option tells the table how to format the date column in the table. It only works if your table includes a date column. If you don’t set this option, the default format in your WordPress settings will be used (see Date Format under the Settings -> General menu).

You can set the date format to any valid date/time format string. For example: F j, Y will format the dates in this format: “August 24, 2016”. See the WordPress Codex for more information.

Example: [posts_table columns="title,date" date_format="F j, Y"]


Was this article helpful?

Related Articles