Hook: category.frontend_url
Last updated on May 21, 2026 05:10
Overview
Type: Filter
Location: app/Models/Category.php
Filters the public URL of a category. Called when $category->frontend_url is accessed. Themes can use this to create custom URL structures for category archives.
Parameters
| Param | Type | Description |
|---|---|---|
$url |
string | Default category URL |
$category |
Category | Category model instance |
Return
Must return string - the final URL.
Usage Example
Use parent slug in category URL for documentation themes:
Hook::addFilter('category.frontend_url', function (string $url, $category) {
if ($category->parent && $category->parent->slug === 'documentation') {
return '/docs/' . $category->slug;
}
return $url;
});
Related Hooks
- post.frontend_url - Customize post public URL
- theme.view.data - Inject data into views