How to Create a WordPress Document Library
A WordPress document library is presents 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 for the WordPress admin, but very few to create a front end document library for users. The ones that do exist have poor ratings and a lot of negative feedback. Read on to discover why Posts Table Pro is perfect for your WordPress document library…
Posts Table Pro – the perfect WordPress document library plugin
The Posts Table Pro WordPress plugin instantly creates interactive WordPress tables. You can use it to display documents, PDF’s, publications or any other types of document in a searchable, sortable table with filters. This makes it easy for people to find the documents they’re looking for and either read them online, or download a file.
In this tutorial, I’ll explain how to use Posts Table Pro 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.
See a document library in action – RJ Lee Group publications library
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 WordPress document library for your own publications.
Posts Table Pro does NOT store your documents for you – you can use WordPress for that. Posts Table Pro’s job is to create a library of documents added to 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 to add documents now.
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.
- 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.
- Activate the plugin and then click on the ‘CPT UI’ link in the left of the WordPress admin (near the bottom).
- 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://[your-domain.com]/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.
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:
- Go to Plugins > Add New and install the Advanced Custom Fields WordPress plugin.
- Activate the plugin and then click on the ‘Custom Fields’ link in the left of the WordPress admin.
- 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.
- Next, you can either click ‘Add Field’ to create additional custom fields if you need more than one.
- 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.
- Or if you’ve finished, scroll up and click the blue ‘Publish’ button.
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.
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 main ways to do this (but check out the bonus tip in a minute!):
- 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.
- 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=”http://katietestsite.wpengine.com/wp-content/uploads/2016/10/sample-document.pdf“>Click to download</a>
Bonus plugin! Use the Page Links To plugin for easier downloading
If you can’t be bothered to create a custom field for your downloadable documents, check out the Page Links To plugin. This free plugin lets people download the file simply by clicking on a title in the document library table.
It works perfectly with Posts Table Pro. It’s ideal if you want people to download directly from the table instead of accessing the single post page. They can simply click on any title in the document library and download the file immediately.
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:
- Go to your custom post type and create a new post for each document that you will be adding to the library.
- Add the document title as the main title at the top of the page.
- 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.
- 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 in the knowledge base, 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.
WordPress document library with links to document posts
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.
WordPress Document library with direct download links
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 knowledge base 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:
- Use Posts Table Pro as a WordPress members directory plugin
- List upcoming events in a WordPress events table
- Create a WordPress video gallery or audio library
- Build a WordPress publications library or knowledge hub
- Create a content table or index of your blog posts or pages
You can buy Posts Table Pro here. And if you like it, register as a Barn2 Media affiliate and get 30% discount for recommending our WordPress plugins! I hope you enjoy creating your WordPress document library!