Hook: post.frontend_url
Last updated on May 20, 2026 19:06
Overview
Type: Filter
Location: app/Models/Post.php
Filters the public-facing URL of a post. Called every time $post->frontend_url is accessed. Useful for themes that need custom URL structures such as wiki-style /docs/slug instead of /posts/slug.
Parameters
| Param | Type | Description |
|---|---|---|
$url |
string | Default generated URL |
$post |
Post | Post model instance |
Return
Must return string - the final public URL.
Usage Example
Redirect wiki-type posts to a /docs/ prefix:
Hook::addFilter('post.frontend_url', function (string $url, $post) {
if ($post->type === 'wiki') {
return '/docs/' . $post->slug;
}
return $url;
});
Related Hooks
- category.frontend_url - Customize category URL
- theme.view.data - Inject data into theme views