1. Home
  2. Knowledge Base
  3. Document Library Pro
  4. Advanced Usage

How to create document category archives using page builders

Document Library Pro comes with basic category archive pages which display documents using the same layout as your blog posts. Most people don't use these because it's better to use the main document library page to list all documents with category filters; or the shortcode to list documents by category.

Alternatively,  you can use a page builder plugin such as Elementor or Divi to create a custom document archive page. Below, we have provided a code snippet and custom shortcode which you can insert into an archive page created using a page builder in order to list documents from the relevant category. If you don't know how to use it then please view our article on using code snippets, or use our customization service.

Step 1: Add the code snippet

function dynamic_doc_library_shortcode( $atts ) {
$term = get_queried_object();

if ( is_a( $term, 'WP_Term' ) && isset( $term->term_id ) ) {
$category_id = $term->term_id;
} else {
return ;
}

return do_shortcode( '[doc_library doc_category="' . esc_attr( $category_id ) . '"]' );
}
add_shortcode( 'dynamic_doc_library', 'dynamic_doc_library_shortcode' );

Step 2: Add the custom shortcode

Now add the shortcode [dynamic_doc_library] to a code or shortcode block in your chosen page builder. This will display documents from the relevant category.

Related Articles

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