How to Create a WordPress Document Library

Published: Updated: April 17, 2017 Category: Tutorials & How-To, WordPress Plugins 0 Comments

wordpress-document-library-tutorialA WordPress document library is an ideal way to give people access to your documents in an easy-to-find format. You can use a document library as a file manager to keep things organised, share resources within your organisation, create a knowledge hub or a publications database.

It’s surprisingly hard to find a good document library WordPress plugin. There are lots of document management and file manager plugins but very few that let you create a document library for your users. The ones that do exist have poor ratings and a lot of negative feedback.

The Posts Table Pro WordPress jQuery plugin lets you create a highly interactive WordPress tables. You can use it to display all sorts of information that is stored on your WordPress website. This might be documents, PDF’s, publications or any other types of document.

In this tutorial, I’ll explain how to use Posts Table Pro to as a document library WordPress plugin. This is a fantastic way to create a document library in WordPress.


Before we start, I’ll show you an example of Posts Table Pro in use for a WordPress publications library.

WordPress document library plugin in action – RJ Lee Group publications library

WordPress publications library database plugin

RJ Lee Group are an industrial forensics analytical laboratory and scientific consulting firm. Their staff make regular presentations and public in peer-reviewed journals, so they wanted a publications library on their website showcasing the firm’s work.

With over 300 publications to list in the library, they needed a user-friendly table that makes it easy to find a specific publication.

They used Posts Table Pro to create a publications library listing their articles. The table displays 25 publications per page with pagination allowing users to view older documents. It includes columns for publication title, citation and date.

Each column can be sorted and a search box above the table lets you further navigate the publications in the list.

1. Decide how to store your documents in the library

Now I’ll tell you how to create a similar document library for your own publications.

Posts Table Pro does NOT store your documents for you – its job is to create a library by displaying the documents which are already stored on your WordPress website. If your documents are already stored on your website, that’s great and you can skip to step 3. Or if you’re still planning your WordPress document library, I’ll tell you how in this section.

Posts, custom posts or pages?

The Posts Table Pro plugin supports standard WordPress posts, pages and custom post types. This means that you can add documents to your library using any of these methods:

  • Add each document as a post in the ‘Posts’ section of the WordPress admin.
  • Create a custom post type called ‘Documents’, ‘Resources’ or similar. This means that there will be a ‘Documents’ or ‘Resources’ section in the left of the WordPress admin where you can store your documents.
  • Add each document as a standard Page in the ‘Pages’ section of the WordPress admin.

Most people use a custom post type for their documents or resources, so that’s what we’ll do in this article. (If you’d rather use standard posts, that’s fine – in step 3, you just need to remove post_type=”documents” from the Post Table Pro shortcode examples in this article. To use pages, just add post_type=”page” to the shortcode instead.)

How to create a WordPress custom post type

Next I’ll tell you how to create a custom post type to store the resources in your WordPress document library. Your custom post type will appear as a separate link in the left hand side of the WordPress admin. You can call it whatever you like, e.g. ‘Documents’, ‘Publications’ or ‘Resources’. You will add each document as a separate post in this section of the admin, and later I’ll show you how to display them as a document library.

  1. Go to Plugins > Add New and install a custom post types WordPress plugin such as Custom Post Types UI. It doesn’t matter how you create your custom post type, but this is the plugin I recommend which is easy to use. If you’re a WordPress developer, you can create your custom post type without using a plugin.
  2. Activate the plugin and then click on the ‘CPT UI’ link in the left of the WordPress admin (near the bottom).
  3. Next create your custom post type:
    • Post Type Slug – this will be used at the end of the URL for each of your documents. e.g. if you type ‘documents’ here then the URL for your documents will be in this format: http://[]/documents/[document-slug]. Use lower case.
    • Plural Label – type the plural version of your custom post type name here. For example if you type ‘Documents’ then the link on the left hand side of the WordPress admin will say ‘Documents’. Use title case.
    • Singular Label – add the singular version of your custom post type name, e.g. ‘Document’. Use title case.
    • Click ‘Add post type‘. The page will refresh and you will see a new section in the left of the WordPress admin called ‘Documents’ (or whatever you added as the Plural Label). That’s where you’ll store everything in your document library.

WordPress document library

View your custom post type

If you try creating a document and clicking ‘View Post’, you can see what the single post page for your documents will look like. This is where people will be taken after they click on a link in your document library (depending on how you set up Posts Table Pro – see below).

If you’re not happy with the layout then you may need to create a custom template for your documents post type. If you don’t know how to code then we’d recommend Codeable for small tasks like this.

How to store extra data about your documents

Now we’ve created a custom post type for your WordPress document library. Next I’ll tell you how to store extra information about each item in your document library.

By default, your Documents custom post type will contain the same information as standard WordPress posts – title, content etc. There’s lots of other information you might want to have in your document library. For example, you might want to divide it into categories. You might want to store information about the publication date, file size or file type. You can store all this in custom fields and taxonomies.

Custom fields, taxonomies or something else?

Here are some tips to help you decide whether to store each piece of data as a custom field or taxonomy:

  • Custom fields – use these to store unique data about each item in your WordPress document library. For example if you’re using your document library to store internal publications then each one might have a unique document number. You would store the document numbers as a custom field.
  • Custom taxonomies – taxonomies are an opportunity to sort and organise data. Use these to store information that will apply to multiple documents in your library. For example, you might want people to be able to filter the document library to view documents from the year 2016. To do this, you would create a taxonomy called ‘Year’ and assign each document to the appropriate year.

You can also use standard WordPress categories and tags to store data about your documents. These also count as ‘taxonomies’ as each tag would be used for multiple categories and tags.

In this tutorial, I’ll show you how to create custom fields for your Documents post type. Creating custom taxonomies is a bit more technical but if you want to do that then WPMU have written a useful guide.

How to create custom fields for your WordPress document library

If you’re a developer then you will already know how to create custom fields, so ignore this bit. If not, this is how to do it:

  1. Go to Plugins > Add New and install the Advanced Custom Fields WordPress plugin.
  2. Activate the plugin and then click on the ‘Custom Fields’ link in the left of the WordPress admin.
  3. On the ‘Field Groups’ page, click ‘Add New’ and enter a name for your field group. This won’t be shown on the website and is the plugin’s way of storing the custom fields relating to your WordPress document library so call it ‘Documents’ or similar. Next click ‘Add Field’ and add all the information, including:
    • Field Label – Add a label for your custom field, e.g. ‘File Type’. This will appear in the WordPress admin.
    • Field Name – Add a slug name for your custom field, e.g. ‘file_type’. This has to be one word and can contain underscores and dashes. The Advanced Custom Fields plugin will use this behind the scenes to store the data.
    • Field Type – Choose an option for the dropdown. This depends on what sort of data you will be storing in the custom field. For example it might be standard text, a date, a downloadable file etc.
    • Default Value – Add a default value to save time if your custom fields are likely to re-use the same information. For example if 99% of the items in your document library are PDF’s then you could enter ‘PDF’ as the default value. This would mean that PDF will automatically be added for each document unless you add something different.
    • Formatting – You can choose to display your custom field exactly as you have entered it (in plain text). Or you can choose to render any HTML you have added to the custom field.
  4. Next, you can either click ‘Add Field’ to create additional custom fields if you need more than one.
  5. When you have created all your custom fields, scroll down to the ‘Location’ section. Select the custom post type you’re using for the WordPress document library, e.g. ‘documents’. This tells Advanced Custom Fields to make those custom fields available to the custom post type you created earlier in this tutorial.
  6. Or if you’ve finished, scroll up and click the blue ‘Publish’ button.

Create custom field for WordPress document library

Now when you add a new document, you will be able to enter information into these custom fields. In step 3, you’ll be able to display them in your document library using Posts Table Pro.

Downloadable documents

Some WordPress document libraries add the documents as actual website content. By this, I mean that you would enter the content of your document within the main content area for your custom post so that people can view it online without downloading anything. If that applies to you then you can skip to step 2.

Other document libraries contain downloadable documents such as PDF’s, Word docs or PowerPoint presentations. There are 2 ways to do this:

  1. Upload the document to the media library (Media > Add New) and copy the File URL. Then add a link (or button, if your theme includes styling for buttons) to the File URL into the main content area for your post or custom post.
  2. Create a custom field to link to the file. This is the only way to let people download files directly from the main document library without having to view the individual post.

To make the file downloadable from the main document library, you need to enter the relevant HTML code into the custom field – simply adding the File URL won’t work as the link will not be clickable.

For example, I would enter this in my custom field (replace the link in italics with your own File URL):

<a href=”“>Click to download</a>

2. Add the documents to the library

Once you’ve planned how you will store your documents and their data, it’s time to add them to the document library. This is a similar process to adding standard WordPress posts:

  1. Go to your custom post type and create a new post for each document that you will be adding to the library.
  2. Add the document title as the main title at the top of the page.
  3. Add a short description in the area where you would normally add the post content. I recommend keeping this short if you will be displaying the description in your document library because that will let you display the full text without being truncated.
  4. Add any custom fields, taxonomies etc. to store the data about your document.

3. Create your WordPress document library

How it’s time for the fun bit – creating a WordPress document library to display your documents.

To do this, you’ll need to install the Posts Table Pro plugin which you can buy here. Once you have purchased, installed and activated the plugin, you can add the Posts Table Pro shortcode to any page of your website to create your document library. The plugin will automatically display all your documents as an interactive table.

As you can see from the documentation, there are dozens of options that let you configure your WordPress document library exactly as you like. To get you started, I’ll give you 2 examples of popular ways to use it for a document library.

This shortcode is suitable if you’ve added the content of your documents directly to your custom post:

[posts_table post_type="documents" columns="title,content,tax:doc_year,cf:file_type" sort_by="tax:doc_year" sort_order="desc"]

It will display the data shown in the below screenshot.


The shortcode has been configured with the following details:

  • Display custom posts in the ‘documents’ custom post type
  • Display columns for Title, Content (i.e. the beginning of the description field), Year (taxonomy) and file type (custom field)
  • Sort the table by year in descending order

Your visitors can click on the title of each document to view the single post page.

This shortcode lets you add direct links to downloadable files to your document library. It will display the data shown in the below screenshot.

[posts_table columns="title,content,tax:doc_year,cf:file_type,cf:download" links="none" post_type="documents" sort_by="title"]


The shortcode has been configured with the following details:

  • Display custom posts in the ‘documents’ custom post type
  • Display columns for Title, Content (i.e. the beginning of the description field), Year (taxonomy), file type (custom field) and Download (custom field – this is where I added the HTML code to display the content of my custom field as a link – see above).
  • Sort the table by year in descending order

Again, copy the above shortcode to get started. You can then use the documentation to configure the document library to your heart’s content.

How to create a private WordPress document library

If you want to make your document library private then there are several ways to do this. For example, you might want to restrict it to your staff members so that the public can’t see this page on your website.

The simplest way to achieve this is to password protect the page that contains your document library. To do this, go to the Edit Page screen and click ‘Edit’ next to ‘Visibility’ in the ‘Publish’ section in the top right corner. You can then password protect the page and give the password to all your users.

If you want a more fancy solution then it’s worth looking at membership plugins. I won’t go into this in detail because it’s a huge area and there are plenty of good resources for creating a membership website or intranet.

Whatever method you use to protect your content, you can also use it to protect your document library.

It’s time to set up the WordPress document library plugin

By the end of this tutorial, you should know how to use the table plugin to create a WordPress document library.

As you can see, Posts Table Pro is ideal as a WordPress document library plugin. Once you’ve finished, there are lots of other ways you can use it. To get even more value for money, you can create tables of other types of content too. For example:

You can buy Posts Table Pro here. And if you like it, register as a Barn2 Media affiliate and get 13% discount for recommending our WordPress plugins! I hope you enjoy creating your WordPress document library!