1. Home
  2. Knowledge Base
  3. Document Library Pro
  4. Document Library Options

Displaying dates in the document library

Document Library Pro includes several shortcode options for how dates are displayed and formatted in the document library. For example, you can tell the plugin which fields are dates so that it will sort by date rather than alphabetically.

These options can only be controlled by adding them directly to the shortcode.

Date columns

The date_columns option is used to specify which fields 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 fields or change the date format. This option should contain one or more fields (as a comma-separated list) using the same syntax as the content option. For example:

[doc_library content="image,title,cf:date,tax:custom_tax" date_columns="cf:date,tax:custom_tax"]

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

Should I use this for the date field or ACF date picker fields?

If you are using the built-in date field, or date picker fields created with Advanced Custom Fields, then you don't need to use the date_columns option. Document Library Pro already knows these columns are dates and handles them appropriately.

The date_columns is only needed for additional date custom fields, for example:

  • You're using a standard WordPress custom field as a date.
  • You're using an ACF text field as a date.
  • You're using another custom fields plugin not supported by Document Library Pro.

Date sorting isn't working

If you're trying to sort by date custom field or taxonomy, you need to make sure you included the column in the date_columns option. For example, if you have a custom field called event_date, then your table shortcode might be:

[doc_library columns="title,cf:event_date" date_columns="cf:event_date" sort_by="cf:event_date"]

Date format

The date_format option tells the table how to format the date field in the library. It only works if your library includes a date field. 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: [doc_library columns="title,date" date_format="F j, Y"]

The date format isn't working for my custom field

If the date format is wrong despite using the date_columns and date_format options in your shortcode, then the plugin where the date custom field is managed/stored is probably overriding the date format.

To fix this, go to the settings for your custom field and look for a date format option. You should probably remove the date_format option from your Document Library Pro shortcode as this might cause conflicts with the date format in the 3rd party plugin.

Related Articles

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