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. 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

In addition, if you are not using the lazy load option, you can sort by any other text-based column present in the library. E.g. sort_by="content".

For lazy loaded libraries, you can only sort by the keywords listed above. This is because the sorting is handled by the server when the products are retrieved from the database.


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.


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

Can I sort by multiple columns?

No, this is not currently possible. The library can only be sorted by a single column.

Can I sort the library by number?

You can only sort a column numerically if you are using a "Number" custom field created using the plugin Advanced Custom Fields and lazy load should be off. Otherwise, the library is sorted alphabetically rather than numerically. This applies to all text-based columns including custom fields and taxonomies.

If you’re using custom fields or taxonomies to store numbers instead of text, then you may wish to sort the library in number order. There is no option for this unless you are using Advanced Custom Fields, but you can achieve this by adding the numbers in a format that will make sense when ordered alphabetically. For example:

  • If you add numbers in the format 1, 2, 3, 4, 5, 6, 7, 8, 9, 10 and 11, then they will be sorted in the following order – 1, 10, 11, 2, 3, 4, etc. This does not look correct.
  • If you’re sorting by a custom field containing numbers 01, 02, 03, 04, 05, 06, 07, 08, 09, 10 and 11, then they will be sorted correctly both alphabetically and numerically.

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.