Overview
The [dlp_category_sections] shortcode automatically loops through all doc_categories taxonomy terms and renders each one as a named section: a heading followed by a [doc_library] document grid scoped to that category.
Use it on any page where you want a self-maintaining, one-shortcode “all categories” document index — new categories appear automatically without editing the page.
Basic Usage
[dlp_category_sections]
This produces an <h2> heading and a 4-column grid for every non-empty category, sorted A–Z.
Attributes
Attributes fall into two groups: section-control attributes (consumed by this shortcode) and pass-through attributes (forwarded to every inner [doc_library] call).
Section-Control Attributes
These attributes control which categories are shown and how the section headings are rendered. They are not passed to [doc_library].
| Attribute | Default | Allowed Values | Description |
|---|---|---|---|
heading_tag | h2 | h1 h2 h3 h4 h5 h6 | HTML heading element used for each category name. |
parent | (empty) | Category slug or numeric term ID | Restricts output to direct and indirect descendants of this category. Omit to show all top-level categories. |
include_categories | (empty — all) | Comma-separated category slugs | Whitelist of categories to show. All others are skipped. |
exclude_categories | (empty) | Comma-separated category slugs | Blacklist of categories to hide. |
orderby | name | name count slug term_id id none | Field used to sort categories. |
order | ASC | ASC DESC | Sort direction. |
empty | hide | hide show | Whether to render a section for categories that currently have zero documents. |
Note on
include_categoriesvsexclude_categories: You can use both together.include_categoriesis applied first (as a whitelist), thenexclude_categoriesremoves any overlap.
Pass-Through Attributes
These attributes are forwarded verbatim to every [doc_library] call generated by the shortcode. The defaults below provide a sensible out-of-the-box grid presentation.
| Attribute | Default | Description |
|---|---|---|
layout | grid | Display layout for each category grid. |
grid_columns | 4 | Number of columns when layout="grid". |
rows_per_page | -1 | Number of documents to show per category. -1 shows all. |
search_box | false | Show a search box inside each category section. |
filters | false | Show filter controls inside each category section. |
pagination | false | Show pagination inside each category section. |
Any other attribute supported by [doc_library] can also be added — it will be passed through to every category grid automatically.
HTML Output Structure
The shortcode produces the following markup:
<div class="dlp-category-sections">
<div class="dlp-category-section">
<h2 class="dlp-category-section-heading">Category Name</h2>
<div class="dlp-category-section-grid">
<!-- [doc_library] output for this category -->
</div>
</div>
<!-- Repeated for each category -->
</div>
CSS classes for styling:
| Class | Element |
|---|---|
dlp-category-sections | Outer wrapper for the entire block |
dlp-category-section | Wrapper for a single category section |
dlp-category-section-heading | The category heading (h2 by default) |
dlp-category-section-grid | Container for the [doc_library] grid output |
Examples
1. Default — all categories, 4-column grid
[dlp_category_sections]
2. Use h3 headings and a 3-column grid
[dlp_category_sections heading_tag="h3" grid_columns="3"]
3. Show only sub-categories of a parent category
[dlp_category_sections parent="policies"]
Replace policies with the slug of your parent category. You can also use the numeric term ID:
[dlp_category_sections parent="42"]
4. Whitelist specific categories, sorted by document count (most first)
[dlp_category_sections include_categories="forms,guides,templates" orderby="count" order="DESC"]
5. Show all categories including empty ones, switch to list layout
[dlp_category_sections empty="show" layout="list"]
Notes
- Automatic updates. Because the shortcode queries live taxonomy terms on render, adding or renaming a category is reflected on the page without any manual edits.
- Pass-through scope. Pass-through attributes apply to all category grids equally. If you need different settings for individual categories, use separate
[doc_library category="slug"]shortcodes instead. empty="show"and zero-count categories. Whenempty="show", a section heading and an empty grid wrapper are still rendered for categories with no documents. The visual result depends on how[doc_library]handles an empty result set.include_categoriesuses slugs. Term IDs are not supported forinclude_categoriesorexclude_categories; use slugs only.parentaccepts slug or ID. Unlike the include/exclude attributes,parentaccepts either a category slug or a numeric term ID.
