Title: get_page_link
Published: April 25, 2014
Last modified: February 24, 2026

---

# get_page_link( int|WP_Post $post, bool $leavename = false, bool $sample = false ): string

## In this article

 * [Description](https://developer.wordpress.org/reference/functions/get_page_link/?output_format=md#description)
 * [Parameters](https://developer.wordpress.org/reference/functions/get_page_link/?output_format=md#parameters)
 * [Return](https://developer.wordpress.org/reference/functions/get_page_link/?output_format=md#return)
 * [Source](https://developer.wordpress.org/reference/functions/get_page_link/?output_format=md#source)
 * [Hooks](https://developer.wordpress.org/reference/functions/get_page_link/?output_format=md#hooks)
 * [Related](https://developer.wordpress.org/reference/functions/get_page_link/?output_format=md#related)
 * [Changelog](https://developer.wordpress.org/reference/functions/get_page_link/?output_format=md#changelog)
 * [User Contributed Notes](https://developer.wordpress.org/reference/functions/get_page_link/?output_format=md#user-contributed-notes)

[ Back to top](https://developer.wordpress.org/reference/functions/get_page_link/?output_format=md#wp--skip-link--target)

Retrieves the permalink for the current page or page ID.

## 󠀁[Description](https://developer.wordpress.org/reference/functions/get_page_link/?output_format=md#description)󠁿

Respects page_on_front. Use this one.

## 󠀁[Parameters](https://developer.wordpress.org/reference/functions/get_page_link/?output_format=md#parameters)󠁿

 `$post`int|[WP_Post](https://developer.wordpress.org/reference/classes/wp_post/)
optional

Post ID or object. Default uses the global `$post`.

`$leavename`booloptional

Whether to keep the page name.

Default:`false`

`$sample`booloptional

Whether it should be treated as a sample permalink.

Default:`false`

## 󠀁[Return](https://developer.wordpress.org/reference/functions/get_page_link/?output_format=md#return)󠁿

 string The page permalink.

## 󠀁[Source](https://developer.wordpress.org/reference/functions/get_page_link/?output_format=md#source)󠁿

    ```php
    function get_page_link( $post = 0, $leavename = false, $sample = false ) {
    	$post = get_post( $post );

    	if ( 'page' === get_option( 'show_on_front' ) && (int) get_option( 'page_on_front' ) === $post->ID ) {
    		$link = home_url( '/' );
    	} else {
    		$link = _get_page_link( $post, $leavename, $sample );
    	}

    	/**
    	 * Filters the permalink for a page.
    	 *
    	 * @since 1.5.0
    	 *
    	 * @param string $link    The page's permalink.
    	 * @param int    $post_id The ID of the page.
    	 * @param bool   $sample  Is it a sample permalink.
    	 */
    	return apply_filters( 'page_link', $link, $post->ID, $sample );
    }
    ```

[View all references](https://developer.wordpress.org/reference/files/wp-includes/link-template.php/)
[View on Trac](https://core.trac.wordpress.org/browser/tags/6.9.4/src/wp-includes/link-template.php#L391)
[View on GitHub](https://github.com/WordPress/wordpress-develop/blob/6.9.4/src/wp-includes/link-template.php#L391-L410)

## 󠀁[Hooks](https://developer.wordpress.org/reference/functions/get_page_link/?output_format=md#hooks)󠁿

 [apply_filters( ‘page_link’, string $link, int $post_id, bool $sample )](https://developer.wordpress.org/reference/hooks/page_link/)

Filters the permalink for a page.

## 󠀁[Related](https://developer.wordpress.org/reference/functions/get_page_link/?output_format=md#related)󠁿

| Uses | Description | 
| [_get_page_link()](https://developer.wordpress.org/reference/functions/_get_page_link/)`wp-includes/link-template.php` |

Retrieves the page permalink.

  | 
| [home_url()](https://developer.wordpress.org/reference/functions/home_url/)`wp-includes/link-template.php` |

Retrieves the URL for the current site where the front end is accessible.

  | 
| [apply_filters()](https://developer.wordpress.org/reference/functions/apply_filters/)`wp-includes/plugin.php` |

Calls the callback functions that have been added to a filter hook.

  | 
| [get_option()](https://developer.wordpress.org/reference/functions/get_option/)`wp-includes/option.php` |

Retrieves an option value based on an option name.

  | 
| [get_post()](https://developer.wordpress.org/reference/functions/get_post/)`wp-includes/post.php` |

Retrieves post data given a post ID or post object.

  |

[Show 3 more](https://developer.wordpress.org/reference/functions/get_page_link/?output_format=md#)
[Show less](https://developer.wordpress.org/reference/functions/get_page_link/?output_format=md#)

| Used by | Description | 
| [get_permalink()](https://developer.wordpress.org/reference/functions/get_permalink/)`wp-includes/link-template.php` |

Retrieves the full permalink for the current post or post ID.

  |

## 󠀁[Changelog](https://developer.wordpress.org/reference/functions/get_page_link/?output_format=md#changelog)󠁿

| Version | Description | 
| [1.5.0](https://developer.wordpress.org/reference/since/1.5.0/) | Introduced. |

## 󠀁[User Contributed Notes](https://developer.wordpress.org/reference/functions/get_page_link/?output_format=md#user-contributed-notes)󠁿

 1.   [Skip to note 3 content](https://developer.wordpress.org/reference/functions/get_page_link/?output_format=md#comment-content-1612)
 2.    [Drew Jaynes](https://profiles.wordpress.org/drewapicture/)  [  10 years ago  ](https://developer.wordpress.org/reference/functions/get_page_link/#comment-1612)
 3.  [You must log in to vote on the helpfulness of this note](https://login.wordpress.org?redirect_to=https%3A%2F%2Fdeveloper.wordpress.org%2Freference%2Ffunctions%2Fget_page_link%2F%23comment-1612)
     Vote results for this note: 1[You must log in to vote on the helpfulness of this note](https://login.wordpress.org?redirect_to=https%3A%2F%2Fdeveloper.wordpress.org%2Freference%2Ffunctions%2Fget_page_link%2F%23comment-1612)
 4.  [html]
      <a href="<?php echo esc_url( get_page_link( 40 ) ); ?>"> <?php esc_html_e(‘
     Map’, ‘textdomain’ ); ?> </a> [/html]
 5.   [Log in to add feedback](https://login.wordpress.org/?redirect_to=https%3A%2F%2Fdeveloper.wordpress.org%2Freference%2Ffunctions%2Fget_page_link%2F%3Freplytocom%3D1612%23feedback-editor-1612)
 6.   [Skip to note 4 content](https://developer.wordpress.org/reference/functions/get_page_link/?output_format=md#comment-content-3868)
 7.    [Mohit Mishra](https://profiles.wordpress.org/mohitmishra/)  [  6 years ago  ](https://developer.wordpress.org/reference/functions/get_page_link/#comment-3868)
 8.  [You must log in to vote on the helpfulness of this note](https://login.wordpress.org?redirect_to=https%3A%2F%2Fdeveloper.wordpress.org%2Freference%2Ffunctions%2Fget_page_link%2F%23comment-3868)
     Vote results for this note: 0[You must log in to vote on the helpfulness of this note](https://login.wordpress.org?redirect_to=https%3A%2F%2Fdeveloper.wordpress.org%2Freference%2Ffunctions%2Fget_page_link%2F%23comment-3868)
 9.      ```php
         // get blog page id.
         $page_for_posts = get_option( 'page_for_posts' );
         ?>
         <a href="<?php echo esc_attr( esc_url( get_page_link( $page_for_posts ) ) ) ?>"><?php esc_html_e( 'Blog Page', 'textdomain' ) ?></a>
         ```
     
 10.  [Log in to add feedback](https://login.wordpress.org/?redirect_to=https%3A%2F%2Fdeveloper.wordpress.org%2Freference%2Ffunctions%2Fget_page_link%2F%3Freplytocom%3D3868%23feedback-editor-3868)

You must [log in](https://login.wordpress.org/?redirect_to=https%3A%2F%2Fdeveloper.wordpress.org%2Freference%2Ffunctions%2Fget_page_link%2F)
before being able to contribute a note or feedback.