1. Home
  2. Knowledge Base
  3. Document Library Pro
  4. Advanced Usage

How to disable sorting in the document library

If you want to disable sorting for individual columns in your document library tables, please see the document_library_pro_column_sortable hook in the Developer Documentation.

Disable all sorting

If you want to completely disable column sorting, you can use the following code. Add it to a custom plugin or inside your theme's functions.php file:

// Disable column sorting
add_filter( 'document_library_pro_data_config', function( $config ) {
    $config['ordering'] = false;
    return $config;
} );

Please note: this will completely disable the ability to sort the table, and means the sort_by option can no longer be used.

Disable sorting on specific pages only

The following code snippet will disable sorting in the tables on specific pages only - simply replace "144" with the ID of the page that you want to disable sorting on:

// Disable column sorting
add_filter( 'document_library_pro_data_config', function( $config ) {
if ( is_page(144) ) {
$config['ordering'] = false;
}
return $config;
} );

How to hide the sort arrows

By default, Document Library Pro will show sort arrows on the column headings to allow the user to sort the table by clicking on that column. If you wish to simply hide the arrows but still allow sorting when clicked,  you can add the following CSS to your site. This will hide the sort arrows for all columns in the table:

.document-library-pro thead th.sorting::before,
.document-library-pro thead th.sorting::after {
    content: none !important;
}

To hide the arrows for individual columns only, you need to add the correct column class to the above code. For example, the title column has a class name of col-title, while the image column has a class name of col-image.

To hide the sorting arrows for the title column, use this CSS:

.document-library-pro thead th.sorting.col-title::before,
.document-library-pro thead th.sorting.col-title::after { 
    content: none !important; 
}

Related Articles

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