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].

AttributeDefaultAllowed ValuesDescription
heading_tagh2h1 h2 h3 h4 h5 h6HTML heading element used for each category name.
parent(empty)Category slug or numeric term IDRestricts output to direct and indirect descendants of this category. Omit to show all top-level categories.
include_categories(empty — all)Comma-separated category slugsWhitelist of categories to show. All others are skipped.
exclude_categories(empty)Comma-separated category slugsBlacklist of categories to hide.
orderbynamename count slug term_id id noneField used to sort categories.
orderASCASC DESCSort direction.
emptyhidehide showWhether to render a section for categories that currently have zero documents.

Note on include_categories vs exclude_categories: You can use both together. include_categories is applied first (as a whitelist), then exclude_categories removes 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.

AttributeDefaultDescription
layoutgridDisplay layout for each category grid.
grid_columns4Number of columns when layout="grid".
rows_per_page-1Number of documents to show per category. -1 shows all.
search_boxfalseShow a search box inside each category section.
filtersfalseShow filter controls inside each category section.
paginationfalseShow 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:

ClassElement
dlp-category-sectionsOuter wrapper for the entire block
dlp-category-sectionWrapper for a single category section
dlp-category-section-headingThe category heading (h2 by default)
dlp-category-section-gridContainer 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. When empty="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_categories uses slugs. Term IDs are not supported for include_categories or exclude_categories; use slugs only.
  • parent accepts slug or ID. Unlike the include/exclude attributes, parent accepts either a category slug or a numeric term ID.