This page redirects to an external site: https://developer.wordpress.org/reference/functions/get_post_permalink/
Languages:
English •
日本語
(Add your language)
Description
Retrieves the permalink for a post with a custom post type.
This function is very similar to get_permalink().
Usage
<code style="color: #000000"><span style="color: #0000BB"><?php get_post_permalink</span><span style="color: #007700">( </span><span style="color: #0000BB">$id</span><span style="color: #007700">, </span><span style="color: #0000BB">$leavename</span><span style="color: #007700">, </span><span style="color: #0000BB">$sample </span><span style="color: #007700">); </span><span style="color: #0000BB">?></span></code>
Default Usage
<code style="color: #000000"><span style="color: #0000BB"><?php get_post_permalink</span><span style="color: #007700">(); </span><span style="color: #0000BB">?></span></code>
Parameters
- $id
- (integer) (optional) Post ID. This parameter is not required when used within The Loop.
- Default: 0
- $leavename
- (boolean) (optional) Whether to keep the post name. When set to true, a structural link will be returned, rather than the actual URI. Example: http://www.example.com/%postname% instead of http://www.example.com/my-post.
- Default: false
- $sample
- (boolean) (optional) Is it a sample permalink? If the post type has extra permastructure and the post's status is draft or pending, a link with the post ID as a GET parameter (e.g. http://example.com/?post=53) will be returned instead of the usual permalink, unless the link is a sample ($sample is true).
- Default: false
Return Values
- (string)
- The permalink for the post, or a WP_Error object if the post does not exist.
Examples
See get_permalink() for examples.
Notes
Changelog
Source Code
get_post_permalink() is located in wp-includes/link-template.php.
Related
get_permalink(),
the_permalink(),
post_permalink(),
permalink_anchor(),
permalink_single_rss()