Using FacetWP to add filter widgets to the document library
Document Library Pro comes with built-in filter dropdowns which you can display above the table of documents. If you would like to add filter widgets to your document libraries then we recommend using it with the FacetWP filter plugin, which we have integrated with.
For example, you might want to add filter widgets if:
- You're using the grid layout for the document library, which doesn't come with filter dropdowns.
- You want to add more advanced filter widgets to the document library.
- You'd like to display filters in the page sidebar instead of above the list of documents.
Follow the instructions below to integrate your document libraries with FacetWP.
This article contains general advice about how to create document libraries with FacetWP filters. This is advanced usage of Document Library Pro and isn't covered by our standard plugin support.
1. Create a Listing template via the Listing Builder in FacetWP
Browse to Settings → FacetWP → Listings and click “Add new”. Then follow the instructions below to allow Document Library Pro to recognise that it will be handling the output for your template.
- a. Ensure the template slug begins with
- Ignore the options on the Display tab because these will automatically be replaced by the document library table or grid.
- On the Query tab, ensure that only the Documents post type is selected. Any other sorting or filtering options you require can be added to the query (e.g. to select documents from a specific category only)
The other details of the document library (e.g. the columns) are taken from Documents → Settings. Since FacetWP will be handling the filtering, the usual Document Library Pro filter dropdowns and search box will automatically be hidden.
2. Set up your filters
For example, you could create facets for Document Categories, Document Tags and the File Type taxonomies.
3. Connect it all together
Now you can create a filtering page using the above Listing template and facets via the shortcodes or PHP functions provided by FacetWP.
For example, the following shortcodes would create a page that contains a document library, search box, and filter widgets for document categories and file types:
Can I edit each tables individually when using FacetWP?
Since the tables are added via a FacetWP Listing template instead of using the
[doc_library] shortcode, you can't use shortcode options to edit each list of documents. Each list will display the documents which you selected using the Query Builder in the Listing template and will inherit the global options in terms of which content to display about your documents, etc.
Instead, we have provided a filter which allows developers to adjust the options supplied to the document library.