Make the title column Download the document in Document Library Pro

Document Library Pro is a powerful plugin for WordPress users seeking efficient management and organization of documents. However, for those striving to enhance user experience and streamline access to documents, a common challenge arises: how to make the title column directly initiate the download process, rather than leading to a separate document page.

To manage this, first make sure the download or link column is present in the table.

Next, add this JS code:

jQuery(function($) {
    $(document).ready(function() {
        $('.posts-table-wrapper').on('click', 'tr', function() {
            let downloadLink = $(this).find('td.col-link a.dlp-download-link')
            
            if (downloadLink.length > 0) {
                let downloadUrl = downloadLink.attr('href')
                let titleTd = $(this).find('td.col-title')
                let titleAnchor = titleTd.find('a')
                
                titleAnchor.attr('href', downloadUrl)
                titleAnchor.attr('target', '_blank')
            }
        })
    })
})

You can add this code on the same page where you have the table, just remember to add <script> at the top and </script> at the very end. You can also use a code snippets plugin like https://wordpress.org/plugins/insert-headers-and-footers/

In conclusion, the integration of JavaScript to convert the title column into a direct download link represents a valuable enhancement for Document Library Pro users. This solution underscores the versatility and extensibility of WordPress plugins, empowering users to tailor functionality to meet their specific needs and preferences.

1 thought on “Make the title column Download the document in Document Library Pro”

  1. This is what I’ve been looking for but haven’t been able to figure out. Have been trawling the documentation for the plugin and they really don’t seem to allow this option.

    That being said, your code doesn’t seem to work. Are there any other requirements around it? E.g. should a certain “download link” display setting be selected?

Leave a Comment

Your email address will not be published. Required fields are marked *

Scroll to Top