Filters the permalink for a post of a custom post type.
Parameters
$post_linkstring- The post’s permalink.
$postWP_Post- The post in question.
$leavenamebool- Whether to keep the post name.
$samplebool- Is it a sample permalink.
Source
return apply_filters( 'post_type_link', $post_link, $post, $leavename, $sample );
Changelog
| Version | Description |
|---|---|
| 3.0.0 | Introduced. |
External Link for custom post type using meta field and post format ( Link ).
Example migrated from Codex:
Append the query string for the custom post type ‘my_custom_post_type’ permalink URLs ( uses add_query_arg() and get_post_type() ):
Here’s a practical example of using the
post_type_linkfilter to remove a custom post type slug (e.g.,team-member) from its permalink, and adjusting the main query to recognize those URLs correctly. (See:pre_get_posts)