1. Document Library Pro
  2. FAQ

Can I add custom fields and taxonomies to the document library?

Document Library Pro comes with all the standard WordPress fields, such as the document title, content, excerpt, featured image, author and date. It also comes with two custom taxonomies: document categories and document tags. It generates other information automatically, such as the file size and type.

You can use any WordPress custom fields or custom taxonomy plugin to create additional fields for your document library. This article explains how to do this.

Custom fields

Custom fields are for storing unique information about each document. Only use custom fields for data that you do not need to group or filter by, for example a document reference number, filename, version number or revision date.

  1. Create as many custom fields as you like using your chosen plugin, and enable it for the dlp_document post type. This will add it to the bottom of the Add/Edit Document page.
  2. Go to the Add/Edit Document page and add information to the custom field for each document.
  3. Display the custom field as a column in the document library table.

Custom taxonomies

Custom taxonomies provide extra ways of grouping your documents. For example, if you want to store the publisher or year for each document, so that users can filter by publisher, language or year, then you should add these as custom taxonomies. You can list each taxonomy in a filter dropdown above the document library so that people can find documents more quickly.

  1. Create as many custom taxonomies as you like using your chosen plugin, and enable it for the dlp_document post type. This will add it to the right hand side of the Add/Edit Document page.
  2. Go to the Add/Edit Document page and tag your documents with the relevant taxonomy terms.
  3. Display the custom taxonomy as a column in the document library table.

Once created, your custom taxonomies will appear in the left of the WordPress admin under Categories and Tags. You can add/edit/delete/restructure your taxonomies centrally from there.

You can use any plugin that allows you to create custom fields or taxonomies. Choose one based on which features you need. We recommend the following free plugins:

Displaying custom fields and taxonomies on the single document page

The instructions above tell you how to create custom fields and taxonomies, and display them on the main document library pages. With some custom coding, you can also display them on the individual page for each document.

If you have already created a custom single document page template then you should add code to output your custom fields and taxonomies there. If you're not using a custom template then you can adapt the code snippets below in order to add custom fields and taxonomies.

Custom Fields

add_action( 'document_library_pro_single_document_details_list_after', function () {
    ?>
    <div class="dlp-document-info-custom-field">
        <span class="dlp-document-info-title"><?php_e( 'Custom Field: ', 'text-domain' ); ?></span>
        <?php echo get_post_meta( get_the_ID(), 'custom_field', true ); ?>
    </div>
    <?php
} );

Custom Taxonomies

add_action( 'document_library_pro_single_document_details_list_after', function () {
    ?>
    <div class="dlp-document-info-custom-tax">
        <span class="dlp-document-info-title"><?php_e( 'Custom Taxonomy: ', 'text-domain' ); ?></span>
        <?php echo get_the_term_list( get_the_ID(), 'custom_taxonomy' ); ?>
    </div>
    <?php
} );

Related Articles

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