WordPress.org

Codex

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

Function Reference/get page link

Description

Retrieves the permalink for the current page (if in The Loop) or any arbitrary page ID if passed as the first argument. All arguments are optional. All arguments default to false.

If $id is passed, it will be the id of the page whose link is returned.

$leavename can be used to toggle off the switching out of "%pagename%" in permalinks.

$sample returns a sample permalink.

Usage

<?php get_page_link($id$leavename$sample); ?>

Parameters

$id
(mixed) (optional) Page ID
Default: false
$leavename
(bool) (optional) Whether to keep page name
Default: false
$sample
(bool) (optional) Is it a sample permalink?
Default: false

Return Value

(string) 
A string containing the permalink.

Example

This example will display a link named "Map", to page with id number 40.

<a href="<?php echo get_page_link(40); ?>">Map</a>

Related

Page Tags: get_all_page_ids(), get_ancestors(), get_page(), get_page_link(), get_page_by_path(), get_page_by_title(), get_page_children(), get_page_hierarchy(), get_page_uri(), get_pages(), is_page(), page_uri_index(), wp_list_pages(), wp_page_menu()

See also index of Function Reference and index of Template Tags.