Filters the permalink for a page.
Parameters
$linkstring- The page’s permalink.
$post_idint- The ID of the page.
$samplebool- Is it a sample permalink.
Source
return apply_filters( 'page_link', $link, $post->ID, $sample );
Changelog
| Version | Description |
|---|---|
| 1.5.0 | Introduced. |
Customizing Permalinks for WordPress Pages Based on Categories
Learn how to dynamically change WordPress page permalinks based on assigned categories. This tutorial will guide you through the process of creating a custom function that checks if a page belongs to a specific category (e.g., “example”) and modifies its permalink structure accordingly. You’ll understand the usage of WordPress hooks and functions like
get_the_category()andadd_filter()to achieve this customization.