post_type_link WordPress Filter Hook

The post_type_link hook is a powerful tool that allows you to change the URL of a post type. This can be extremely useful if you want to change the slug of a post type, or if you want to change the URL structure of a post type.

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

Filters the permalink for a post of a custom post type.


Parameters

$post_link

(string)The post's permalink.

$post

(WP_Post)The post in question.

$leavename

(bool)Whether to keep the post name.

$sample

(bool)Is it a sample permalink.


Top ↑

More Information

post_type_link is a filter applied to the permalink URL for a post or custom post type prior to being returned by the function get_post_permalink() .


Top ↑

Source

File: wp-includes/link-template.php

View on Trac



Top ↑

Changelog

Changelog
VersionDescription
3.0.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