get_page_link

The timeline below displays how wordpress function get_page_link has changed across different WordPress versions. If a version is not listed, refer to the next available version below.

WordPress Version: 5.4

/**
 * Retrieves the permalink for the current page or page ID.
 *
 * Respects page_on_front. Use this one.
 *
 * @since 1.5.0
 *
 * @param int|WP_Post $post      Optional. Post ID or object. Default uses the global `$post`.
 * @param bool        $leavename Optional. Whether to keep the page name. Default false.
 * @param bool        $sample    Optional. Whether it should be treated as a sample permalink.
 *                               Default false.
 * @return string The page permalink.
 */
function get_page_link($post = false, $leavename = false, $sample = false)
{
    $post = get_post($post);
    if ('page' === get_option('show_on_front') && 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);
}

WordPress Version: 4.6

/**
 * Retrieves the permalink for the current page or page ID.
 *
 * Respects page_on_front. Use this one.
 *
 * @since 1.5.0
 *
 * @param int|WP_Post $post      Optional. Post ID or object. Default uses the global `$post`.
 * @param bool        $leavename Optional. Whether to keep the page name. Default false.
 * @param bool        $sample    Optional. Whether it should be treated as a sample permalink.
 *                               Default false.
 * @return string The page permalink.
 */
function get_page_link($post = false, $leavename = false, $sample = false)
{
    $post = get_post($post);
    if ('page' == get_option('show_on_front') && $post->ID == get_option('page_on_front')) {
        $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);
}

WordPress Version: 4.3

/**
 * Retrieve the permalink for current page or page ID.
 *
 * Respects page_on_front. Use this one.
 *
 * @since 1.5.0
 *
 * @param int|object $post      Optional. Post ID or object.
 * @param bool       $leavename Optional, defaults to false. Whether to keep page name.
 * @param bool       $sample    Optional, defaults to false. Is it a sample permalink.
 * @return string The page permalink.
 */
function get_page_link($post = false, $leavename = false, $sample = false)
{
    $post = get_post($post);
    if ('page' == get_option('show_on_front') && $post->ID == get_option('page_on_front')) {
        $link = home_url('/');
    } else {
        $link = _get_page_link($post, $leavename, $sample);
    }
    /**
     * Filter 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);
}

WordPress Version: 4.1

/**
 * Retrieve the permalink for current page or page ID.
 *
 * Respects page_on_front. Use this one.
 *
 * @since 1.5.0
 *
 * @param int|object $post Optional. Post ID or object.
 * @param bool $leavename Optional, defaults to false. Whether to keep page name.
 * @param bool $sample Optional, defaults to false. Is it a sample permalink.
 * @return string The page permalink.
 */
function get_page_link($post = false, $leavename = false, $sample = false)
{
    $post = get_post($post);
    if ('page' == get_option('show_on_front') && $post->ID == get_option('page_on_front')) {
        $link = home_url('/');
    } else {
        $link = _get_page_link($post, $leavename, $sample);
    }
    /**
     * Filter 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);
}

WordPress Version: 3.9

/**
 * Retrieve the permalink for current page or page ID.
 *
 * Respects page_on_front. Use this one.
 *
 * @since 1.5.0
 *
 * @param int|object $post Optional. Post ID or object.
 * @param bool $leavename Optional, defaults to false. Whether to keep page name.
 * @param bool $sample Optional, defaults to false. Is it a sample permalink.
 * @return string
 */
function get_page_link($post = false, $leavename = false, $sample = false)
{
    $post = get_post($post);
    if ('page' == get_option('show_on_front') && $post->ID == get_option('page_on_front')) {
        $link = home_url('/');
    } else {
        $link = _get_page_link($post, $leavename, $sample);
    }
    /**
     * Filter 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);
}

WordPress Version: 3.7

/**
 * Retrieve the permalink for current page or page ID.
 *
 * Respects page_on_front. Use this one.
 *
 * @since 1.5.0
 *
 * @param int|object $post Optional. Post ID or object.
 * @param bool $leavename Optional, defaults to false. Whether to keep page name.
 * @param bool $sample Optional, defaults to false. Is it a sample permalink.
 * @return string
 */
function get_page_link($post = false, $leavename = false, $sample = false)
{
    $post = get_post($post);
    if ('page' == get_option('show_on_front') && $post->ID == get_option('page_on_front')) {
        $link = home_url('/');
    } else {
        $link = _get_page_link($post, $leavename, $sample);
    }
    return apply_filters('page_link', $link, $post->ID, $sample);
}