1. Document Library Pro
  2. Document Library Options

Document library fields

Document Library Pro gives you full control over the data displayed in the document library. You can do this on the plugin settings page, or by using the content option in the [doc_library] shortcode.

Available fields

This option controls the information which is displayed about each document. The available options are:

  • Table layout - idtitlecontentexcerptimagedatedate_modifiedauthordoc_categoriesdoc_tagsfile_sizefile_typestatuslink, or any custom field or taxonomy.
  • Grid layout - titlecontentexcerptimage, doc_categories, file_sizefile_type, link.
WordPress document library column options

You can list as many fields as you like and in any order. You must separate each field with a comma. It doesn’t matter if there are spaces before or after the comma, but there must not be any spaces before or after the = sign.

Here’s an example of a shortcode to display documents with fields for title, date, document author, excerpt and button:

[doc_library content="title,date,author,excerpt,button"]

  • The id field will display the document ID, which is a unique number used internally by WordPress for each document. (Table layout only.)
  • The title field is the main document title.
  • The content field will show the document content but will be truncated to 15 words. You can modify this by setting the content_length option. For the grid layout, if there is no content then the excerpt will be displayed instead.
  • The excerpt field will show the document excerpt. It will be truncated to 55 words (the WordPress default) but themes and plugins sometimes override this value. To have precise control over the length, you can set the excerpt_length option. For the grid layout, if there is no excerpt then the content will be displayed instead.
  • The image field will display the featured image (i.e. the document thumbnail) for the document or page (see image_size option to set a custom size for the table layout). If you are using the grid layout then the image field will display the featured image if available, otherwise it will show a file type icon.
  • The date field will display the date that the document was published. (Table layout only.)
  • The date_modified field will display the date that the document was last updated. (Table layout only.)
  • The author field displays the document author’s display name. (Table layout only.)
  • The doc_categories will display the categories for each document (comma-separated if there is more than one).
  • The doc_tags field will display the tags for each document (comma-separated if there is more than one). (Table layout only.)
  • The status field will show the status of the document (e.g. draft, pending, publish, etc). (Table layout only.)
  • The link field will contain a link to the document and/or a preview link.

Please note that the above field names are case sensitive and should always be lower case. (If you're using custom column headings then these can be any case.)

Custom field columns

(Table layout only)

Custom fields are a good way to include other types of content in the document library. You can use them to store links, buttons, icons, shortcodes from other plugins, etc. You should add the full HTML code or shortcode to the custom field so that the document library can display it correctly. If you’re adding shortcodes to your custom fields, you will need to set shortcodes to true.

You can add custom fields to your document library using the format cf:<field name>. If you are using Advanced Custom Fields, the field name can be found under the “Field Name” column in the Custom Fields menu.

Here’s an example adding two custom fields – my_field1 and my_field2:

[doc_library content"title,content,cf:my_field1,cf:my_field2"]

Tip: You can use any custom fields plugin to create custom fields. We recommend Advanced Custom Fields for creating custom fields only; or Custom Posts Type UI or Pods if you need to create custom fields along with a custom document type and/or custom taxonomies.

Custom fields created using the Toolset plugin

If you're using Toolset to create your custom fields, then you need slightly different syntax to display them in the document library.

Toolset adds wpcf- to the start of the custom field name, so if you create a custom field called 'link' (for example) then the correct syntax will be wpcf-link. This means that if you want to create a document library with columns for name and a custom field called 'link' then you would need to add it as follows:
[doc_library columns="name,cf:wpcf-link"]

ACF repeater fields

If you're using Advanced Custom Fields Pro repeater fields, you can create a column using the name of the parent repeater field. This column will list the content of all the repeater fields for that document, separated by commas. It is not possible to display repeater sub-fields as separate columns in the document library.

Custom taxonomy columns

(Table layout only)

For taxonomies (other than document categories and tags), use the format tax:<taxonomy slug>. So, for example, to display for a custom taxonomy with the slug document_type, you would use:

[doc_library columns="title,content,tax:document_type"]

You can find the taxonomy slug by going to the WordPress admin and finding the main page which lists those taxonomies. For example, WooCommerce product categories are edited under the Products → Categories menu. On that page, the URL at the top of the screen shows “…edit-tags.php?taxonomy=product_cat….”. The ‘product_cat’ bit after the equals is the taxonomy slug you need to use.

Author column

(Table layout only)

The author column displays the name of the WordPress user who created the document. If you're creating an author column and need more flexibility - for example because you are creating a document library and want to add the Document author - then you should use a different type of column instead. For example:

  • You could use the categories or tags column and rename it to 'Author'.
  • You could create a custom taxonomy for 'Author'.

Creating custom columns programmatically

(Table layout only)

Developer can use custom columns to display data programmatically which is not available as one of the standard document library columns.

Choosing your own column headings

(Table layout only)

You can set custom column headings by adding a : (colon) after the column name. You can rename as many columns as you like. You can use this method to change the wording and/or capitalization of column names.

If you don’t change the column heading then the default one will be used. For example, the default heading for the document title is "Title", but if you wanted the heading “"MY HEADING" instead, you would use:

[doc_library columns="title:MY HEADING,date,author,content"]

WordPress Table Custom Column Headings

Custom column headings for Title, Image, Date, Categories & Tags

Here’s a more complex example where we want to set the title column heading to “Property Description”, the date column to “Added On”, a custom taxonomy to “Type” and a custom field to “Sale Price (£)”:

[doc_library document_type=property columns="title:Property Description,date:Added On,tax:listing_cat:Type,cf:valuation:Sale Price (£)"]

Note: In the above example, the taxonomy and custom field columns now have two colons – one to define the taxonomy (or custom field) name, and the other to set the column heading. This is perfectly fine as long as you use the correct syntax. For these column types, everything after the second colon will be used as the custom heading, including the space between the 2 words.

Removing a column heading

(Table layout only)

If you would like to remove the column heading completely use the keyword blank after the colon. For example:[doc_library columns="title:blank,content,categories"]

When you do this, the column names will be removed and only the sort arrows will be hidden. If you want to hide the header row completely then you can do this using custom CSS.

How to hide a column

(Table layout only)

You can easily hide columns simply by removing them from the list of columns in the document library. This will remove the column from the document library.

If you wish to hide a column on specific devices only (e.g. mobiles or document libraryts), please see the column_breakpoints option which allows you to do this.

Related Articles

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