1. Document Library Pro
  2. Document Library Options

Displaying shortcodes in the document library

The shortcodes option allows you to display content generated by any shortcodes used on your site, or page layout builders such as Gutenberg. It also tells the plugin to render any HTML or other formatting from your documents, instead of displaying it as plain text.

Note: This article is about using shortcodes to display content inside the fields of the document library, such as in the content field. Please see our separate article about how to use a shortcode to list documents.

Examples of shortcodes displayed in a document library

There are lots of reasons why you might want to display shortcodes, HTML or other formatting within a document library. For example:

  • WordPress provides several built-in shortcodes for displaying audio files, videos, media playlists and image galleries. You can display these embedded media files directly in a document library.
  • Your theme or another plugin might provide shortcodes to add buttons, icons or other styles. You can include these in a document library.
  • You might want text formatting such as bold, paragraph breaks or hyperlinks to appear in the document library, instead of having this stripped out.

Why don't my shortcodes or Gutenberg layouts display?

By default, shortcodes is set to false which will remove all shortcodes from your document library, as well as disabling other formatting such as HTML. This is because:

  1. Processing shortcode content can take a significant amount of time – especially for large document librarys – so enabling them can have a performance impact on your site.
  2. Shortcodes often add HTML to the content which makes it difficult to limit content to a set number of words (see content_length and excerpt_length). For this reason, if you enable shortcodes, then the full content is always displayed and the content_length option is ignored.

The same happens if you have used the Gutenberg editor to create the content of the documents that you are displaying.

How to display shortcode content and Gutenberg layouts

You can display shortcodes and other formatting by adding shortcodes="true" to the Document Library Pro shortcode.

Once you've done this, you can add shortcodes to any of the fields that you are displaying as fields in Document Library Pro. For example, if your document library contains a content field then you can enable the Shortcodes option and add shortcodes to the content of your documents so that they appear in the document library.

Example:

[doc_library fields="image,title,content" shortcodes="true"]

Related Articles

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