Skip to content

Commit 2b7c7c6

Browse files
committed
Fix product slug default value and improve permalinks documentation
- Change default product_slug from 'kb/products' to 'kb/product' for consistency - Add Pro feature overview to README and readme.txt - Simplify PERMALINKS-TUTORIAL.md with clearer structure and examples - Remove overly technical details and focus on practical usage - Improve troubleshooting section with common solutions
1 parent de04e72 commit 2b7c7c6

4 files changed

Lines changed: 62 additions & 150 deletions

File tree

README.md

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -42,6 +42,8 @@ Effortlessly create a powerful, multi-product knowledge base. Boost your support
4242

4343
### Pro features
4444

45+
[Knowledge Base Pro](https://webberzone.com/plugins/knowledgebase/#pro) enhances the plugin with advanced features for larger documentation sites, including ratings and feedback, a help widget, a powerful custom permalinks engine, premium layouts, and additional admin tools.
46+
4547
-__Article Rating & Feedback System__ — Collect binary or 5-star feedback with optional follow-up questions, admin alerts, Bayesian sorting, and GDPR-friendly tracking modes.
4648
- 💬 __Help Widget__ — Offer an in-app support hub with live search, suggested articles, and a contact form inside a floating assistant.
4749
- 🧭 __Custom Permalinks Engine__ — Craft advanced URL structures for articles, sections, tags, and products using dynamic placeholders.

docs/PERMALINKS-TUTORIAL.md

Lines changed: 57 additions & 149 deletions
Original file line numberDiff line numberDiff line change
@@ -1,184 +1,92 @@
1-
# Knowledge Base Permalinks Tutorial
1+
# Knowledge Base Permalinks
22

3-
This guide explains how permalinks work in the WebberZone Knowledge Base plugin and how to customise them in both the free and Pro versions. Follow the sections below to configure URLs, understand placeholder behaviour, and troubleshoot issues.
3+
This guide explains how Knowledge Base handles URLs and how to configure custom permalink structures in [Pro](https://webberzone.com/plugins/knowledgebase/).
44

5-
## 1. Permalink Settings Overview
5+
## Quick start
66

7-
All permalink settings are located in **Knowledge Base → Settings → General** under the **Permalinks** section. The Setup Wizard also exposes these fields during onboarding.
7+
- **Free version**: Set your slugs in **Knowledge Base → Settings → Permalinks**
8+
- **Pro version**: Enable **custom permalinks** and use placeholders like `%product_name%` or `%section_name%` in your article structure
89

9-
### 1.1 Available Settings
10+
## Permalink settings
1011

11-
- **Knowledge Base slug** (`kb_slug`): Sets the base path for the Knowledge Base post type. Default: `knowledgebase`. Used in free version and as fallback in Pro.
12-
- **Product slug** (`product_slug`): Base path for product archives. Default: `kb/product`. Supports placeholders in Pro (e.g., `support/product`).
13-
- **Section slug** (`category_slug`): Base path for section archives. Default: `kb/section`. Supports placeholders in Pro (e.g., `support/product/%product_name%/%section_name%`).
14-
- **Tags slug** (`tag_slug`): Base path for tag archives. Default: `kb/tags`. Supports placeholders in Pro (e.g., `support/tag`).
15-
- **Article Permalink Structure** (`article_permalink`): Custom structure for article URLs. **Pro feature only**. Default: empty (uses `{kb_slug}/%postname%`).
12+
All permalink settings are located in **Knowledge Base → Settings → General** under the **Permalinks** section.
1613

17-
### 1.2 Free Version Behavior
14+
### Available settings
1815

19-
- Free version uses standard WordPress permastruct rewrite rules for all taxonomies.
20-
- Article URLs follow the pattern: `{kb_slug}/%postname%`
21-
- Example: If `kb_slug` is `knowledgebase`, articles appear at `/knowledgebase/article-name/`
22-
- Taxonomy slugs can be customized but do not support placeholders.
23-
- To use placeholders and custom article structures, upgrade to Pro.
16+
- **Knowledge Base slug** (`kb_slug`): Sets the base path for the Knowledge Base. Default: `knowledgebase`
17+
- **Product slug** (`product_slug`): Base path for product archives. Default: `kb/product`
18+
- **Section slug** (`category_slug`): Base path for section archives. Default: `kb/section`
19+
- **Tags slug** (`tag_slug`): Base path for tag archives. Default: `kb/tags`
20+
- **Article Permalink Structure** (`article_permalink`): Custom structure for articles. **Pro feature only**
2421

25-
## 2. Pro: Custom Permalinks Engine
22+
## Pro: custom permalinks engine
2623

27-
The Pro module activates custom permalink handling when:
24+
Pro adds a custom permalinks engine that lets you control your URL structure using placeholders.
2825

29-
- A custom `article_permalink` structure is set (with or without placeholders)
30-
- Taxonomy slugs include placeholders (e.g., `support/product/%product_name%/%section_name%`)
26+
**When this activates:**
3127

32-
### 2.1 Supported Placeholders
28+
- Pro is installed and activated
29+
- You enter a custom structure in the article permalink field (anything other than the default `%postname%`)
3330

34-
```text
35-
%product_name% %section_name% %section_id%
36-
%tag_name% %post_id% %postname% %author%
37-
```
38-
39-
These map to query variables used when building rewrite rules and are sanitised before use.
40-
41-
Placeholders can be filtered with `wzkb_custom_permalink_placeholders`, allowing developers to register additional tokens.
42-
43-
### 2.2 How Custom Permalinks Work
44-
45-
The Pro version automatically builds your article and taxonomy URLs based on the structures you define:
46-
47-
1. **Rewrite rules are generated** - Custom rewrite rules are created for articles, products, sections, and tags based on your structures.
48-
2. **Placeholders get replaced** - Each placeholder like `%product_name%` or `%section_name%` is replaced with the actual product or section assigned to that article.
49-
3. **URLs are built automatically** - The plugin combines your custom structure with the replaced placeholders to create the final URL.
50-
4. **Smart conflict handling** - When multiple structures share the same base path (e.g., article and section structures both starting with `support/product/`), the plugin prioritizes article rules to prevent misrouting.
51-
5. **Permastruct is disabled** - When custom structures are used, WordPress's default taxonomy permastruct rules are disabled to avoid conflicts. Custom rewrite rules handle all routing instead.
52-
53-
**Example:** If you set:
54-
55-
- `kb_slug`: `support/knowledgebase`
56-
- `article_permalink`: `support/product/%product_name%/%section_name%/%postname%`
57-
58-
And create an article titled "Installation Guide" in the "Getting Started" section of the "Widget Suite" product, the URL becomes:
59-
`/support/product/widget-suite/getting-started/installation-guide/`
60-
61-
### 2.3 What Each Placeholder Does
62-
63-
- **%product_name%** - Replaced with the product slug (e.g., `widget-suite`)
64-
- **%section_name%** - Replaced with the section slug (e.g., `getting-started`)
65-
- **%section_id%** - Replaced with the section ID number (e.g., `42`)
66-
- **%tag_name%** - Replaced with the tag slug (e.g., `troubleshooting`)
67-
- **%postname%** - Replaced with the article slug (e.g., `installation-guide`)
68-
- **%post_id%** - Replaced with the article ID number (e.g., `123`)
69-
- **%author%** - Replaced with the author username (e.g., `john-smith`)
70-
71-
**Tip:** Hierarchical placeholders like `%section_name%` can include parent sections, creating nested URLs like `/parent-section/child-section/`.
31+
**Supported placeholders:**
7232

73-
## 3. Building Custom Structures
33+
- `%product_name%` — The product slug (from your Products taxonomy)
34+
- `%section_name%` — The top-level section slug for articles
35+
- `%postname%` — The article slug
36+
- `%post_id%` — The article ID
37+
- `%author%` — The author username
7438

75-
### 3.1 Example: Custom Prefix with Product → Section → Article
39+
**How custom permalinks work:**
7640

77-
```text
78-
kb_slug: support/knowledgebase
79-
product_slug: support/product
80-
category_slug: support/product/%product_name%/%section_name%
81-
article_permalink: support/product/%product_name%/%section_name%/%postname%
82-
```
83-
84-
- Produces article URLs like `/support/product/widget-suite/getting-started/installing-widget-suite/`
85-
- Produces section URLs like `/support/product/widget-suite/getting-started/`
86-
- Produces product URLs like `/support/product/widget-suite/`
87-
- Custom prefix `support/` is shared across all structures to avoid KB slug prepending
88-
- Requires each article to have a product and section assigned; otherwise the placeholder resolves to an empty segment
89-
90-
### 3.2 Example: Simple Structures Without Placeholders
91-
92-
```text
93-
kb_slug: knowledgebase
94-
product_slug: kb/product
95-
category_slug: kb/section
96-
tag_slug: kb/tags
97-
article_permalink: %product_name%/%section_name%/%postname%
98-
```
41+
1. You define a structure using placeholders
42+
2. Pro generates the appropriate rewrite rules
43+
3. Articles use your custom structure
44+
4. Taxonomy archives (products, sections, tags) use their configured slugs
9945

100-
- Product URLs: `/kb/product/widget-suite/` (term name appended automatically)
101-
- Section URLs: `/kb/section/getting-started/` (term name appended automatically)
102-
- Tag URLs: `/kb/tags/troubleshooting/` (term name appended automatically)
103-
- Article URLs: `/knowledgebase/widget-suite/getting-started/installing-widget-suite/`
46+
**Example:**
10447

105-
### 3.3 Example: Numeric Identifiers
48+
Set `kb_slug` to `help` and `article_permalink` to:
10649

10750
```text
108-
article_permalink: %section_id%/%post_id%/%postname%
51+
%product_name%/%section_name%/%postname%
10952
```
11053

111-
- Helpful for legacy systems needing numeric identifiers in the URL
112-
- Produces URLs like `/42/123/article-slug/`
113-
- Rewrite tags for `section_id` and `post_id` are registered automatically
114-
115-
### 3.4 Term Archive Structures with Placeholders
116-
117-
- **Sections with product context**: `category_slug` set to `support/product/%product_name%/%section_name%` nests sections under their products
118-
- **Tags with section context**: `tag_slug` set to `support/product/%product_name%/%section_name%/%tag_name%` provides full context
119-
- When taxonomy slugs include placeholders, custom rewrite rules are generated to handle the dynamic segments
120-
121-
## 4. Configuration Workflow
122-
123-
1. **Plan taxonomy usage**: Decide which placeholders are meaningful for your data hierarchy.
124-
2. **Update Knowledge Base → Settings → General → Permalinks** with desired structures.
125-
3. **Save settings** to trigger rewrite rule regeneration (automatic in setup and admin UI).
126-
4. **Flush rewrite rules**: Visit **Settings → Permalinks** and click **Save Changes** to ensure WordPress recognizes the new rules.
127-
5. **Assign terms** consistently (products, sections, tags) so placeholders resolve correctly.
128-
6. **Test URLs**:
129-
- Visit an article, product, section, and tag page.
130-
- Verify the URL matches your configured structure.
131-
- Use the WordPress Rewrite Rules Inspector or `wp rewrite list` CLI if needed.
132-
133-
## 5. How Pro Handles Custom Structures
134-
135-
### 5.1 Rewrite Rule Generation
54+
Result: `https://example.com/help/wordpress/getting-started/`
13655

137-
When Pro is enabled and custom structures are detected:
56+
**Note:** `%section_name%` for articles always returns the top-level parent slug, not the full hierarchy.
13857

139-
1. **Custom rewrite rules are created** for articles, products, sections, and tags based on your configured structures
140-
2. **Taxonomy permastruct is disabled** to prevent conflicts with custom rules
141-
3. **Article rules are prioritized** to ensure article URLs are matched before product/section archives
142-
4. **Child section rules are conditionally disabled** when article structures have more segments than section structures, preventing misrouting
58+
## Configuration workflow
14359

144-
### 5.2 Permalink Generation
60+
1. Open Knowledge Base → Settings → General
61+
2. Configure your base slugs (kb_slug, product_slug, etc.)
62+
3. Pro users: set your custom article permalink structure
63+
4. Save changes
14564

146-
When generating permalinks for articles and taxonomies:
65+
> **Important:** After changing permalink settings, visit Settings → Permalinks in WordPress to flush your rewrite rules. This prevents 404 errors.
14766
148-
1. **Placeholders are replaced** with actual term/post values
149-
2. **Term slugs are appended** automatically for taxonomy structures without explicit placeholders
150-
3. **KB slug is intelligently prepended** only when the custom structure doesn't already start with the KB slug's first segment
151-
4. **Final URL is constructed** and returned via `get_term_link()` and `get_permalink()` filters
67+
## Troubleshooting
15268

153-
### 5.3 Fallback Behavior Without Pro
69+
### 404 errors after changing settings
15470

155-
If Pro is not enabled but custom structures are configured:
71+
Visit Settings → Permalinks in WordPress to flush your rewrite rules.
15672

157-
- **Permastruct rewrite rules remain active** to ensure URLs work
158-
- **Custom article structures are ignored** and default `{kb_slug}/%postname%` is used
159-
- **Taxonomy slugs work** but placeholders are not supported
160-
- **No custom rewrite rules are generated** - WordPress handles routing via permastruct
73+
### URLs not matching your structure
16174

162-
## 6. Developer Hooks & Extensibility
75+
- Check you've entered a custom structure (not just `%postname%`)
76+
- Ensure Pro is active
77+
- Verify your placeholder syntax
16378

164-
- `wzkb_custom_permalink_placeholders`: Register extra placeholders or override default mappings.
165-
- `wzkb_article_permalink_structure` and `wzkb_term_permalink_structure`: Filter the resolved path before it is prefixed with the KB slug.
166-
- `wzkb_after_setting_output`: Used by Pro to inject placeholder documentation beneath the settings header for admins.
79+
### Conflicts with other plugins
16780

168-
## 7. Troubleshooting Tips
81+
Some SEO plugins modify rewrite rules. If you experience conflicts:
16982

170-
- **404 errors**: Visit **Settings → Permalinks** and click **Save Changes** to flush rewrite rules. This is the most common fix.
171-
- **Empty placeholders**: Ensure articles have the required product/section/tag assignments. Missing assignments result in empty URL segments.
172-
- **Wrong content loading**: If an article URL loads a product/section archive instead, flush rewrite rules. Pro prioritizes article rules, but rule order depends on proper flushing.
173-
- **Conflicting slugs**: Avoid reusing the KB slug for other pages. Pro attempts to resolve clashes by detecting shared prefixes, but unique slugs prevent ambiguity.
174-
- **Taxonomy URLs not working**: If product/section/tag URLs return 404, ensure their slugs are configured in settings and rewrite rules are flushed.
175-
- **Testing root-level URLs**: When using `%postname%` without a prefix, verify that article slugs do not collide with regular posts or pages.
176-
- **Pro not enabled**: Custom article structures are ignored if Pro is not active. Free version uses default `{kb_slug}/%postname%` structure.
83+
- Test with other plugins disabled
84+
- Check your rewrite rules using a plugin like [Rewrite Rules Inspector](https://wordpress.org/plugins/rewrite-rules-inspector/)
85+
- Priority is given to articles over taxonomy archives to prevent conflicts
17786

178-
## 8. Summary
87+
## Summary
17988

180-
- **Free version** supports basic slug customization for taxonomies and default article URLs using the KB slug.
181-
- **Pro version** unlocks placeholder-driven structures for articles and taxonomies with intelligent rewrite rule generation and conflict resolution.
182-
- **Custom prefixes** (e.g., `support/product/`) allow you to organize URLs outside the KB slug hierarchy.
183-
- **Consistent taxonomy assignments** and thoughtful structure planning ensure clean, SEO-friendly URLs tailored to your knowledge base.
184-
- **Rewrite rule flushing** is essential after any permalink setting changes to ensure WordPress recognizes the new URL patterns.
89+
- Free version: configure base slugs for articles and taxonomies
90+
- Pro version: build custom URL structures using placeholders
91+
- Always flush rewrite rules after changing permalink settings
92+
- Pro handles smart conflict resolution between articles and taxonomies

includes/class-cpt.php

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -257,7 +257,7 @@ public static function register_taxonomies() {
257257

258258
$catslug = self::sanitize_slug( \wzkb_get_option( 'category_slug', 'kb/section' ) );
259259
$tagslug = self::sanitize_slug( \wzkb_get_option( 'tag_slug', 'kb/tags' ) );
260-
$productslug = self::sanitize_slug( \wzkb_get_option( 'product_slug', 'kb/products' ) );
260+
$productslug = self::sanitize_slug( \wzkb_get_option( 'product_slug', 'kb/product' ) );
261261

262262
// Register products taxonomy first.
263263
// Disable permastruct rewrite only if Pro is enabled and custom article structure is used, to avoid conflicts.

readme.txt

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -35,6 +35,8 @@ Effortlessly create a powerful, multi-product knowledge base. Boost your support
3535

3636
### Pro features
3737

38+
[Knowledge Base Pro](https://webberzone.com/plugins/knowledgebase/#pro) enhances the plugin with advanced features for larger documentation sites, including ratings and feedback, a help widget, a powerful custom permalinks engine, premium layouts, and additional admin tools.
39+
3840
- ⭐ __Article Rating & Feedback System__ — Collect binary or 5-star feedback with optional follow-up questions, admin alerts, Bayesian sorting, and GDPR-friendly tracking modes.
3941
- 💬 __Help Widget__ — Offer an in-app support hub with live search, suggested articles, and a contact form inside a floating assistant.
4042
- 🧭 __Custom Permalinks Engine__ — Craft advanced URL structures for articles, sections, tags, and products using dynamic placeholders.

0 commit comments

Comments
 (0)