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

Document library sort options

Document Library Pro comes with two options for sorting the document library when it first loads. These appear in Documents → Settings → Display.

Once the library 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 library by when it is first displayed. Defaults to date which is the date the document was published.

You can order by any column in the library, or by any of the following keywords (whether or not they are included in your library):

  • id – sort by document ID
  • title – sort by document title
  • menu_order – sort by the ‘order’ option (as listed in your site's primary menu)
  • date – sort by the publish date of the document (note: see here to sort by custom field date columns)
  • name – sort by document ‘slug’
  • modified – sort by last modified date
  • comment_count – sort by number of comments
  • rand – random order

Sorting is handled by the server, so the sort_by option accepts the keywords listed above.

Examples

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

Sort using content column in library:  [doc_library content="image,title,content,doc_author" sort_by="content"]

Sort using custom field column in library:  [doc_library content="image,title,excerpt,cf:event" sort_by="cf:event"]

Sort order

The direction to use for sorting by when the library 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 library by listing items in alphabetical order, then the default will be correct.

Example

[doc_library content="title,content" sort_by="date" sort_order="asc"]

How to sort by date or number

Yes, if you're using the table layout then you can sort custom taxonomy or custom field columns by number or date. To do this, open the advanced column options for that column, and change the 'Column type' to 'Number' or 'Date'.

You may also wish to change the date format.

Can I sort by multiple columns?

Yes. Enable the Multi-column sorting option on the 'Display' tab of the plugin settings to let visitors sort the table by more than one column at a time (up to two columns). This is useful when two fields matter together, such as category and date, or file type and file size.

The library is sorted by the first column, and any documents with the same value are then sorted by the second column.

Multi-column sorting is not available in legacy mode.

Sorting folders

Document Library Pro also has a Folders option, in which the documents appear within folders based on their categories.

On the plugin settings page, you can sort the folders by folder name, category ID, category slug, category order (menu order), and the number of terms. Select the sorting direction to choose the sorting order (i.e. ascending or descending).

There are also folders_order_by and folders_order shortcode options which you can use to set the sort type and directly in the shortcode, with the following options

  • folders_order_by options:
    • title - category name
    • term_id - category ID
    • slug - category slug
    • term_order - category order (menu order)
    • count - number of terms
  • folders_order options:
    • asc - sort in ascending order
    • desc - sort in descending order

For example, the shortcode [doc_library folders="true" folders_order_by="count" folders_order="desc"] would list documents in folders, with the folders with the most numbers of documents first.

Sorting the content of category and taxonomy columns

If a document has more than one terms selected for a category or taxonomy, then these will appear as a comma separated list in the category/taxonomy columns of the document library. They are listed in alphabetical order. For example, a document with 3 categories might have them listed as "Presentations, Training, Videos".

If you'd like to change this then you can use a plugin such as Custom Taxonomy Order.

Related Articles

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