post_link WordPress Filter Hook

The post_link hook is used to filter the permalink for a post. This hook is executed before the post is saved, so it can be used to change the post permalink.

apply_filters( 'post_link', string $permalink, WP_Post $post, bool $leavename ) #

Filters the permalink for a post.


Description

Only applies to posts with post_type of ‘post’.


Top ↑

Parameters

$permalink

(string)The post's permalink.

$post

(WP_Post)The post in question.

$leavename

(bool)Whether to keep the post name.


Top ↑

More Information

post_link is a filter applied to the permalink URL for a post prior to returning the processed url by the function get_permalink().

This filter only applies to posts with post_type of ‘post’. For that filter which applies to custom post type look post_type_link.


Top ↑

Source

File: wp-includes/link-template.php

View on Trac



Top ↑

Changelog

Changelog
VersionDescription
1.5.0Introduced.

The content displayed on this page has been created in part by processing WordPress source code files which are made available under the GPLv2 (or a later version) license by theĀ Free Software Foundation. In addition to this, the content includes user-written examples and information. All material is subject to review and curation by the WPPaste.com community.

Show More
Show More