Filters the permalink structure for a post before token replacement occurs.
Description
Only applies to posts with post_type of ‘post’.
Parameters
$permalink
string- The site’s permalink structure.
$post
WP_Post- The post in question.
$leavename
bool- Whether to keep the post name.
Source
$permalink = apply_filters( 'pre_post_link', $permalink, $post, $leavename );
Changelog
Version | Description |
---|---|
3.0.0 | Introduced. |
Modifying Pre-Post Links in WordPress
we will learn how to modify the default permalink structure of your WordPress posts using the pre_post_link filter. We will write a function to customize the permalink and then add and remove this filter.
Step 1: Add the Filter
Step 2: Remove the Filter