Template System
WordPress template hierarchy and layout structure.
Template Hierarchy
WPDocs uses the standard WordPress template hierarchy for the wpdocs_doc post type:
single-wpdocs_doc.php— Individual documentation pagearchive-wpdocs_doc.php— Archive (auto-redirects to first doc)index.php— Fallback (auto-redirects to first doc)
Three-Column Layout
The main layout uses CSS Flexbox with three regions:
┌──────────────────────────────────────────────────────┐
│ NAVBAR: Search bar │ Version │ Social icons │ Theme │
├──────────┬──────────────────────────┬────────────────┤
│ SIDEBAR │ MAIN CONTENT │ TOC (Premium) │
│ Logo │ │ │
│ Sections │ Section badge │ On this page │
│ └ Pages │ H1 Page Title │ ├ Section 1 │
│ │ Description │ ├ Section 2 │
│ │ │ └ Section 3 │
│ │ Rich HTML content... │ │
│ │ │ │
│ │ ← Previous Next → │ │
├──────────┴──────────────────────────┴────────────────┤
│ FOOTER: © 2026 Site Name │ Powered by FW │
└──────────────────────────────────────────────────────┘
Template Parts
docs-sidebar.php
The left sidebar with logo and navigation. Key behaviors:
- Logo area at top with light/dark mode image switching
- Sections queried via
doc_sectiontaxonomy, sorted by_wpdocs_order - Current page highlighted with blue background
- Free version shows max 3 sections with upgrade prompt
- Uses
stickypositioning — scrolls with page but sticks under navbar
docs-toc.php
The “On this page” right sidebar (Premium). How it works:
- Rendered as an empty
<ul>container - JavaScript scans all
H2andH3headings from the content - Generates anchor links with auto-generated IDs
- IntersectionObserver highlights the current heading as you scroll
- H3 items are indented under their parent H2
Previous / Next Navigation
Built into single-wpdocs_doc.php. The function wpdocs_get_prev_next() flattens all docs in sidebar order (sections → pages within each) and finds the adjacent entries.