WordPress.org

Ready to get started?Download WordPress

Codex

Attention Interested in functions, hooks, classes, or methods? Check out the new WordPress Code Reference!

Function Reference/get post permalink

Contents

Description

Retrieves the permalink for a post with a custom post type.

This function is very similar to get_permalink().

Usage

<?php get_post_permalink$id$leavename$sample ); ?>

Default Usage

<?php get_post_permalink(); ?>

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()

See also index of Function Reference and index of Template Tags.
This article is marked as in need of editing. You can help Codex by editing it.