WordPress V5.0+Template Tag Reference Guide as of Version 5.2
Presented by DBS > Interactive Development :
Permalink Tags
Get Page Link get_page_link();
Retrieves the permalink for the current page (if in The Loop) or any arbitrary page ID if passed as the first argument.
<?php get_page_link($id, $leavename, $sample); ?>
$id
Integer • Default: 0
(Optional) Page ID.
$leavename
Boolean • Default: false
(Optional) Whether to keep page name.
$sample
Boolean • Default: false
(Optional) Is it a sample permalink.
Get Permalink get_permalink();
Returns the permalink to a post for use in PHP. It does NOT display the permalink and can be used outside of The Loop. Note that when used outside The Loop on a posts page (index, archive, etc.) without the ID parameter, it will return the URL of the last post in The Loop, not the permalink for the current page.
<?php $permalink = get_permalink($id); ?>
$id
Integer • Default: The current post ID, when used in The Loop.
(Optional) The numeric ID for a post.
Get Post Permalink get_post_permalink();
The get_post_permalink template tag retrieves the permalink for a post with a custom post type.
<?php get_post_permalink($id, $leavename, $sample); ?>
$id
Integer • Default: 0
(Optional) Post ID.
$leavename
Boolean • Default: false
(Optional) Whether to keep post name.
$sample
Boolean • Default: false
(Optional) Is it a sample permalink.
Get Search Link get_search_link();
Returns the permalink to a post for use in PHP. It does NOT display the permalink and can be used outside of The Loop. Note that when used outside The Loop on a posts page (index, archive, etc.) without the ID parameter, it will return the URL of the last post in The Loop, not the permalink for the current page.
<?php get_search_link($query); ?>
$query
String • Default: ''
(Optional) The query string to use. If empty the current query is used.
Permalink Anchorpermalink_anchor();
Outputs a permalink anchor identifier or id (<a id="....) for a post. This is useful for linking to a particular post on a page displaying several posts, such as an archive page. This tag must be within The Loop.
<?php permalink_anchor($type); ?>
$type
String • Default: 'id'
Type of anchor to output. Valid values are: 'id' - Anchor equals numeric post ID or 'title' - Anchor equals postname, i.e. post slug.
Post Permalinkpost_permalink();
Returns the permalink for a post with a custom post type.
<?php post_permalink(); ?>
No parameters.
The Feed Linkthe_feed_link();
The get_post_permalink template tag retrieves the permalink for a post with a custom post type.
<?php the_feed_link($anchor, $feed); ?>
$anchor
String • Default: ''
The link's anchor text.
$feed
String • Default: default feed
(Optional) Feed type.
The Permalinkthe_permalink();
Displays the URL for the permalink to the post currently being processed in The Loop. This tag must be within The Loop, and is generally used to display the permalink for each post, when the posts are being displayed. Since this template tag is limited to displaying the permalink for the post that is being processed, you cannot use it to display the permalink to an arbitrary post on your blog. Refer to get_permalink() if you want to get the permalink for a post, given its unique post id.
<?php the_permalink(); ?>
No parameters.