get_post_permalink

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

WordPress Version: 6.1

/**
 * Retrieves the permalink for a post of a custom post type.
 *
 * @since 3.0.0
 * @since 6.1.0 Returns false if the post does not exist.
 *
 * @global WP_Rewrite $wp_rewrite WordPress rewrite component.
 *
 * @param int|WP_Post $post      Optional. Post ID or post object. Default is the global `$post`.
 * @param bool        $leavename Optional. Whether to keep post name. Default false.
 * @param bool        $sample    Optional. Is it a sample permalink. Default false.
 * @return string|false The post permalink URL. False if the post does not exist.
 */
function get_post_permalink($post = 0, $leavename = false, $sample = false)
{
    global $wp_rewrite;
    $post = get_post($post);
    if (!$post) {
        return false;
    }
    $post_link = $wp_rewrite->get_extra_permastruct($post->post_type);
    $slug = $post->post_name;
    $force_plain_link = wp_force_plain_post_permalink($post);
    $post_type = get_post_type_object($post->post_type);
    if ($post_type->hierarchical) {
        $slug = get_page_uri($post);
    }
    if (!empty($post_link) && (!$force_plain_link || $sample)) {
        if (!$leavename) {
            $post_link = str_replace("%{$post->post_type}%", $slug, $post_link);
        }
        $post_link = home_url(user_trailingslashit($post_link));
    } else {
        if ($post_type->query_var && (isset($post->post_status) && !$force_plain_link)) {
            $post_link = add_query_arg($post_type->query_var, $slug, '');
        } else {
            $post_link = add_query_arg(array('post_type' => $post->post_type, 'p' => $post->ID), '');
        }
        $post_link = home_url($post_link);
    }
    /**
     * Filters the permalink for a post of a custom post type.
     *
     * @since 3.0.0
     *
     * @param string  $post_link The post's permalink.
     * @param WP_Post $post      The post in question.
     * @param bool    $leavename Whether to keep the post name.
     * @param bool    $sample    Is it a sample permalink.
     */
    return apply_filters('post_type_link', $post_link, $post, $leavename, $sample);
}

WordPress Version: 5.7

/**
 * Retrieves the permalink for a post of a custom post type.
 *
 * @since 3.0.0
 *
 * @global WP_Rewrite $wp_rewrite WordPress rewrite component.
 *
 * @param int|WP_Post $id        Optional. Post ID or post object. Default is the global `$post`.
 * @param bool        $leavename Optional. Whether to keep post name. Default false.
 * @param bool        $sample    Optional. Is it a sample permalink. Default false.
 * @return string|WP_Error The post permalink.
 */
function get_post_permalink($id = 0, $leavename = false, $sample = false)
{
    global $wp_rewrite;
    $post = get_post($id);
    if (is_wp_error($post)) {
        return $post;
    }
    $post_link = $wp_rewrite->get_extra_permastruct($post->post_type);
    $slug = $post->post_name;
    $force_plain_link = wp_force_plain_post_permalink($post);
    $post_type = get_post_type_object($post->post_type);
    if ($post_type->hierarchical) {
        $slug = get_page_uri($post);
    }
    if (!empty($post_link) && (!$force_plain_link || $sample)) {
        if (!$leavename) {
            $post_link = str_replace("%{$post->post_type}%", $slug, $post_link);
        }
        $post_link = home_url(user_trailingslashit($post_link));
    } else {
        if ($post_type->query_var && (isset($post->post_status) && !$force_plain_link)) {
            $post_link = add_query_arg($post_type->query_var, $slug, '');
        } else {
            $post_link = add_query_arg(array('post_type' => $post->post_type, 'p' => $post->ID), '');
        }
        $post_link = home_url($post_link);
    }
    /**
     * Filters the permalink for a post of a custom post type.
     *
     * @since 3.0.0
     *
     * @param string  $post_link The post's permalink.
     * @param WP_Post $post      The post in question.
     * @param bool    $leavename Whether to keep the post name.
     * @param bool    $sample    Is it a sample permalink.
     */
    return apply_filters('post_type_link', $post_link, $post, $leavename, $sample);
}

WordPress Version: 5.5

/**
 * Retrieves the permalink for a post of a custom post type.
 *
 * @since 3.0.0
 *
 * @global WP_Rewrite $wp_rewrite WordPress rewrite component.
 *
 * @param int|WP_Post $id        Optional. Post ID or post object. Default is the global `$post`.
 * @param bool        $leavename Optional. Whether to keep post name. Default false.
 * @param bool        $sample    Optional. Is it a sample permalink. Default false.
 * @return string|WP_Error The post permalink.
 */
function get_post_permalink($id = 0, $leavename = false, $sample = false)
{
    global $wp_rewrite;
    $post = get_post($id);
    if (is_wp_error($post)) {
        return $post;
    }
    $post_link = $wp_rewrite->get_extra_permastruct($post->post_type);
    $slug = $post->post_name;
    $draft_or_pending = get_post_status($post) && in_array(get_post_status($post), array('draft', 'pending', 'auto-draft', 'future'), true);
    $post_type = get_post_type_object($post->post_type);
    if ($post_type->hierarchical) {
        $slug = get_page_uri($post);
    }
    if (!empty($post_link) && (!$draft_or_pending || $sample)) {
        if (!$leavename) {
            $post_link = str_replace("%{$post->post_type}%", $slug, $post_link);
        }
        $post_link = home_url(user_trailingslashit($post_link));
    } else {
        if ($post_type->query_var && (isset($post->post_status) && !$draft_or_pending)) {
            $post_link = add_query_arg($post_type->query_var, $slug, '');
        } else {
            $post_link = add_query_arg(array('post_type' => $post->post_type, 'p' => $post->ID), '');
        }
        $post_link = home_url($post_link);
    }
    /**
     * Filters the permalink for a post of a custom post type.
     *
     * @since 3.0.0
     *
     * @param string  $post_link The post's permalink.
     * @param WP_Post $post      The post in question.
     * @param bool    $leavename Whether to keep the post name.
     * @param bool    $sample    Is it a sample permalink.
     */
    return apply_filters('post_type_link', $post_link, $post, $leavename, $sample);
}

WordPress Version: 5.3

/**
 * Retrieves the permalink for a post of a custom post type.
 *
 * @since 3.0.0
 *
 * @global WP_Rewrite $wp_rewrite WordPress rewrite component.
 *
 * @param int|WP_Post $id        Optional. Post ID or post object. Default is the global `$post`.
 * @param bool        $leavename Optional, defaults to false. Whether to keep post name. Default false.
 * @param bool        $sample    Optional, defaults to false. Is it a sample permalink. Default false.
 * @return string|WP_Error The post permalink.
 */
function get_post_permalink($id = 0, $leavename = false, $sample = false)
{
    global $wp_rewrite;
    $post = get_post($id);
    if (is_wp_error($post)) {
        return $post;
    }
    $post_link = $wp_rewrite->get_extra_permastruct($post->post_type);
    $slug = $post->post_name;
    $draft_or_pending = get_post_status($post) && in_array(get_post_status($post), array('draft', 'pending', 'auto-draft', 'future'));
    $post_type = get_post_type_object($post->post_type);
    if ($post_type->hierarchical) {
        $slug = get_page_uri($post);
    }
    if (!empty($post_link) && (!$draft_or_pending || $sample)) {
        if (!$leavename) {
            $post_link = str_replace("%{$post->post_type}%", $slug, $post_link);
        }
        $post_link = home_url(user_trailingslashit($post_link));
    } else {
        if ($post_type->query_var && (isset($post->post_status) && !$draft_or_pending)) {
            $post_link = add_query_arg($post_type->query_var, $slug, '');
        } else {
            $post_link = add_query_arg(array('post_type' => $post->post_type, 'p' => $post->ID), '');
        }
        $post_link = home_url($post_link);
    }
    /**
     * Filters the permalink for a post of a custom post type.
     *
     * @since 3.0.0
     *
     * @param string  $post_link The post's permalink.
     * @param WP_Post $post      The post in question.
     * @param bool    $leavename Whether to keep the post name.
     * @param bool    $sample    Is it a sample permalink.
     */
    return apply_filters('post_type_link', $post_link, $post, $leavename, $sample);
}

WordPress Version: 4.9

/**
 * Retrieves the permalink for a post of a custom post type.
 *
 * @since 3.0.0
 *
 * @global WP_Rewrite $wp_rewrite
 *
 * @param int|WP_Post $id        Optional. Post ID or post object. Default is the global `$post`.
 * @param bool        $leavename Optional, defaults to false. Whether to keep post name. Default false.
 * @param bool        $sample    Optional, defaults to false. Is it a sample permalink. Default false.
 * @return string|WP_Error The post permalink.
 */
function get_post_permalink($id = 0, $leavename = false, $sample = false)
{
    global $wp_rewrite;
    $post = get_post($id);
    if (is_wp_error($post)) {
        return $post;
    }
    $post_link = $wp_rewrite->get_extra_permastruct($post->post_type);
    $slug = $post->post_name;
    $draft_or_pending = get_post_status($post) && in_array(get_post_status($post), array('draft', 'pending', 'auto-draft', 'future'));
    $post_type = get_post_type_object($post->post_type);
    if ($post_type->hierarchical) {
        $slug = get_page_uri($post);
    }
    if (!empty($post_link) && (!$draft_or_pending || $sample)) {
        if (!$leavename) {
            $post_link = str_replace("%{$post->post_type}%", $slug, $post_link);
        }
        $post_link = home_url(user_trailingslashit($post_link));
    } else {
        if ($post_type->query_var && (isset($post->post_status) && !$draft_or_pending)) {
            $post_link = add_query_arg($post_type->query_var, $slug, '');
        } else {
            $post_link = add_query_arg(array('post_type' => $post->post_type, 'p' => $post->ID), '');
        }
        $post_link = home_url($post_link);
    }
    /**
     * Filters the permalink for a post of a custom post type.
     *
     * @since 3.0.0
     *
     * @param string  $post_link The post's permalink.
     * @param WP_Post $post      The post in question.
     * @param bool    $leavename Whether to keep the post name.
     * @param bool    $sample    Is it a sample permalink.
     */
    return apply_filters('post_type_link', $post_link, $post, $leavename, $sample);
}

WordPress Version: 4.6

/**
 * Retrieves the permalink for a post of a custom post type.
 *
 * @since 3.0.0
 *
 * @global WP_Rewrite $wp_rewrite
 *
 * @param int $id         Optional. Post ID. Default uses the global `$post`.
 * @param bool $leavename Optional, defaults to false. Whether to keep post name. Default false.
 * @param bool $sample    Optional, defaults to false. Is it a sample permalink. Default false.
 * @return string|WP_Error The post permalink.
 */
function get_post_permalink($id = 0, $leavename = false, $sample = false)
{
    global $wp_rewrite;
    $post = get_post($id);
    if (is_wp_error($post)) {
        return $post;
    }
    $post_link = $wp_rewrite->get_extra_permastruct($post->post_type);
    $slug = $post->post_name;
    $draft_or_pending = get_post_status($id) && in_array(get_post_status($id), array('draft', 'pending', 'auto-draft', 'future'));
    $post_type = get_post_type_object($post->post_type);
    if ($post_type->hierarchical) {
        $slug = get_page_uri($id);
    }
    if (!empty($post_link) && (!$draft_or_pending || $sample)) {
        if (!$leavename) {
            $post_link = str_replace("%{$post->post_type}%", $slug, $post_link);
        }
        $post_link = home_url(user_trailingslashit($post_link));
    } else {
        if ($post_type->query_var && (isset($post->post_status) && !$draft_or_pending)) {
            $post_link = add_query_arg($post_type->query_var, $slug, '');
        } else {
            $post_link = add_query_arg(array('post_type' => $post->post_type, 'p' => $post->ID), '');
        }
        $post_link = home_url($post_link);
    }
    /**
     * Filters the permalink for a post of a custom post type.
     *
     * @since 3.0.0
     *
     * @param string  $post_link The post's permalink.
     * @param WP_Post $post      The post in question.
     * @param bool    $leavename Whether to keep the post name.
     * @param bool    $sample    Is it a sample permalink.
     */
    return apply_filters('post_type_link', $post_link, $post, $leavename, $sample);
}

WordPress Version: 4.4

/**
 * Retrieve the permalink for a post with a custom post type.
 *
 * @since 3.0.0
 *
 * @global WP_Rewrite $wp_rewrite
 *
 * @param int $id         Optional. Post ID.
 * @param bool $leavename Optional, defaults to false. Whether to keep post name.
 * @param bool $sample    Optional, defaults to false. Is it a sample permalink.
 * @return string|WP_Error The post permalink.
 */
function get_post_permalink($id = 0, $leavename = false, $sample = false)
{
    global $wp_rewrite;
    $post = get_post($id);
    if (is_wp_error($post)) {
        return $post;
    }
    $post_link = $wp_rewrite->get_extra_permastruct($post->post_type);
    $slug = $post->post_name;
    $draft_or_pending = get_post_status($id) && in_array(get_post_status($id), array('draft', 'pending', 'auto-draft', 'future'));
    $post_type = get_post_type_object($post->post_type);
    if ($post_type->hierarchical) {
        $slug = get_page_uri($id);
    }
    if (!empty($post_link) && (!$draft_or_pending || $sample)) {
        if (!$leavename) {
            $post_link = str_replace("%{$post->post_type}%", $slug, $post_link);
        }
        $post_link = home_url(user_trailingslashit($post_link));
    } else {
        if ($post_type->query_var && (isset($post->post_status) && !$draft_or_pending)) {
            $post_link = add_query_arg($post_type->query_var, $slug, '');
        } else {
            $post_link = add_query_arg(array('post_type' => $post->post_type, 'p' => $post->ID), '');
        }
        $post_link = home_url($post_link);
    }
    /**
     * Filter the permalink for a post with a custom post type.
     *
     * @since 3.0.0
     *
     * @param string  $post_link The post's permalink.
     * @param WP_Post $post      The post in question.
     * @param bool    $leavename Whether to keep the post name.
     * @param bool    $sample    Is it a sample permalink.
     */
    return apply_filters('post_type_link', $post_link, $post, $leavename, $sample);
}

WordPress Version: 4.3

/**
 * Retrieve the permalink for a post with a custom post type.
 *
 * @since 3.0.0
 *
 * @global WP_Rewrite $wp_rewrite
 *
 * @param int $id         Optional. Post ID.
 * @param bool $leavename Optional, defaults to false. Whether to keep post name.
 * @param bool $sample    Optional, defaults to false. Is it a sample permalink.
 * @return string|WP_Error The post permalink.
 */
function get_post_permalink($id = 0, $leavename = false, $sample = false)
{
    global $wp_rewrite;
    $post = get_post($id);
    if (is_wp_error($post)) {
        return $post;
    }
    $post_link = $wp_rewrite->get_extra_permastruct($post->post_type);
    $slug = $post->post_name;
    $draft_or_pending = isset($post->post_status) && in_array($post->post_status, array('draft', 'pending', 'auto-draft', 'future'));
    $post_type = get_post_type_object($post->post_type);
    if ($post_type->hierarchical) {
        $slug = get_page_uri($id);
    }
    if (!empty($post_link) && (!$draft_or_pending || $sample)) {
        if (!$leavename) {
            $post_link = str_replace("%{$post->post_type}%", $slug, $post_link);
        }
        $post_link = home_url(user_trailingslashit($post_link));
    } else {
        if ($post_type->query_var && (isset($post->post_status) && !$draft_or_pending)) {
            $post_link = add_query_arg($post_type->query_var, $slug, '');
        } else {
            $post_link = add_query_arg(array('post_type' => $post->post_type, 'p' => $post->ID), '');
        }
        $post_link = home_url($post_link);
    }
    /**
     * Filter the permalink for a post with a custom post type.
     *
     * @since 3.0.0
     *
     * @param string  $post_link The post's permalink.
     * @param WP_Post $post      The post in question.
     * @param bool    $leavename Whether to keep the post name.
     * @param bool    $sample    Is it a sample permalink.
     */
    return apply_filters('post_type_link', $post_link, $post, $leavename, $sample);
}

WordPress Version: 4.2

/**
 * Retrieve the permalink for a post with a custom post type.
 *
 * @since 3.0.0
 *
 * @param int $id Optional. Post ID.
 * @param bool $leavename Optional, defaults to false. Whether to keep post name.
 * @param bool $sample Optional, defaults to false. Is it a sample permalink.
 * @return string The post permalink.
 */
function get_post_permalink($id = 0, $leavename = false, $sample = false)
{
    global $wp_rewrite;
    $post = get_post($id);
    if (is_wp_error($post)) {
        return $post;
    }
    $post_link = $wp_rewrite->get_extra_permastruct($post->post_type);
    $slug = $post->post_name;
    $draft_or_pending = isset($post->post_status) && in_array($post->post_status, array('draft', 'pending', 'auto-draft', 'future'));
    $post_type = get_post_type_object($post->post_type);
    if ($post_type->hierarchical) {
        $slug = get_page_uri($id);
    }
    if (!empty($post_link) && (!$draft_or_pending || $sample)) {
        if (!$leavename) {
            $post_link = str_replace("%{$post->post_type}%", $slug, $post_link);
        }
        $post_link = home_url(user_trailingslashit($post_link));
    } else {
        if ($post_type->query_var && (isset($post->post_status) && !$draft_or_pending)) {
            $post_link = add_query_arg($post_type->query_var, $slug, '');
        } else {
            $post_link = add_query_arg(array('post_type' => $post->post_type, 'p' => $post->ID), '');
        }
        $post_link = home_url($post_link);
    }
    /**
     * Filter the permalink for a post with a custom post type.
     *
     * @since 3.0.0
     *
     * @param string  $post_link The post's permalink.
     * @param WP_Post $post      The post in question.
     * @param bool    $leavename Whether to keep the post name.
     * @param bool    $sample    Is it a sample permalink.
     */
    return apply_filters('post_type_link', $post_link, $post, $leavename, $sample);
}

WordPress Version: 4.1

/**
 * Retrieve the permalink for a post with a custom post type.
 *
 * @since 3.0.0
 *
 * @param int $id Optional. Post ID.
 * @param bool $leavename Optional, defaults to false. Whether to keep post name.
 * @param bool $sample Optional, defaults to false. Is it a sample permalink.
 * @return string The post permalink.
 */
function get_post_permalink($id = 0, $leavename = false, $sample = false)
{
    global $wp_rewrite;
    $post = get_post($id);
    if (is_wp_error($post)) {
        return $post;
    }
    $post_link = $wp_rewrite->get_extra_permastruct($post->post_type);
    $slug = $post->post_name;
    $draft_or_pending = isset($post->post_status) && in_array($post->post_status, array('draft', 'pending', 'auto-draft'));
    $post_type = get_post_type_object($post->post_type);
    if ($post_type->hierarchical) {
        $slug = get_page_uri($id);
    }
    if (!empty($post_link) && (!$draft_or_pending || $sample)) {
        if (!$leavename) {
            $post_link = str_replace("%{$post->post_type}%", $slug, $post_link);
        }
        $post_link = home_url(user_trailingslashit($post_link));
    } else {
        if ($post_type->query_var && (isset($post->post_status) && !$draft_or_pending)) {
            $post_link = add_query_arg($post_type->query_var, $slug, '');
        } else {
            $post_link = add_query_arg(array('post_type' => $post->post_type, 'p' => $post->ID), '');
        }
        $post_link = home_url($post_link);
    }
    /**
     * Filter the permalink for a post with a custom post type.
     *
     * @since 3.0.0
     *
     * @param string  $post_link The post's permalink.
     * @param WP_Post $post      The post in question.
     * @param bool    $leavename Whether to keep the post name.
     * @param bool    $sample    Is it a sample permalink.
     */
    return apply_filters('post_type_link', $post_link, $post, $leavename, $sample);
}

WordPress Version: 0.1

/**
 * Retrieve the permalink for a post with a custom post type.
 *
 * @since 3.0.0
 *
 * @param int $id Optional. Post ID.
 * @param bool $leavename Optional, defaults to false. Whether to keep post name.
 * @param bool $sample Optional, defaults to false. Is it a sample permalink.
 * @return string
 */
function get_post_permalink($id = 0, $leavename = false, $sample = false)
{
    global $wp_rewrite;
    $post = get_post($id);
    if (is_wp_error($post)) {
        return $post;
    }
    $post_link = $wp_rewrite->get_extra_permastruct($post->post_type);
    $slug = $post->post_name;
    $draft_or_pending = isset($post->post_status) && in_array($post->post_status, array('draft', 'pending', 'auto-draft'));
    $post_type = get_post_type_object($post->post_type);
    if ($post_type->hierarchical) {
        $slug = get_page_uri($id);
    }
    if (!empty($post_link) && (!$draft_or_pending || $sample)) {
        if (!$leavename) {
            $post_link = str_replace("%{$post->post_type}%", $slug, $post_link);
        }
        $post_link = home_url(user_trailingslashit($post_link));
    } else {
        if ($post_type->query_var && (isset($post->post_status) && !$draft_or_pending)) {
            $post_link = add_query_arg($post_type->query_var, $slug, '');
        } else {
            $post_link = add_query_arg(array('post_type' => $post->post_type, 'p' => $post->ID), '');
        }
        $post_link = home_url($post_link);
    }
    /**
     * Filter the permalink for a post with a custom post type.
     *
     * @since 3.0.0
     *
     * @param string  $post_link The post's permalink.
     * @param WP_Post $post      The post in question.
     * @param bool    $leavename Whether to keep the post name.
     * @param bool    $sample    Is it a sample permalink.
     */
    return apply_filters('post_type_link', $post_link, $post, $leavename, $sample);
}

WordPress Version: 3.9

/**
 * Retrieve the permalink for a post with a custom post type.
 *
 * @since 3.0.0
 *
 * @param int $id Optional. Post ID.
 * @param bool $leavename Optional, defaults to false. Whether to keep post name.
 * @param bool $sample Optional, defaults to false. Is it a sample permalink.
 * @return string
 */
function get_post_permalink($id = 0, $leavename = false, $sample = false)
{
    global $wp_rewrite;
    $post = get_post($id);
    if (is_wp_error($post)) {
        return $post;
    }
    $post_link = $wp_rewrite->get_extra_permastruct($post->post_type);
    $slug = $post->post_name;
    $draft_or_pending = isset($post->post_status) && in_array($post->post_status, array('draft', 'pending', 'auto-draft'));
    $post_type = get_post_type_object($post->post_type);
    if (!empty($post_link) && (!$draft_or_pending || $sample)) {
        if (!$leavename) {
            if ($post_type->hierarchical) {
                $slug = get_page_uri($id);
            }
            $post_link = str_replace("%{$post->post_type}%", $slug, $post_link);
        }
        $post_link = home_url(user_trailingslashit($post_link));
    } else {
        if ($post_type->query_var && (isset($post->post_status) && !$draft_or_pending)) {
            $post_link = add_query_arg($post_type->query_var, $slug, '');
        } else {
            $post_link = add_query_arg(array('post_type' => $post->post_type, 'p' => $post->ID), '');
        }
        $post_link = home_url($post_link);
    }
    /**
     * Filter the permalink for a post with a custom post type.
     *
     * @since 3.0.0
     *
     * @param string  $post_link The post's permalink.
     * @param WP_Post $post      The post in question.
     * @param bool    $leavename Whether to keep the post name.
     * @param bool    $sample    Is it a sample permalink.
     */
    return apply_filters('post_type_link', $post_link, $post, $leavename, $sample);
}

WordPress Version: 3.7

/**
 * Retrieve the permalink for a post with a custom post type.
 *
 * @since 3.0.0
 *
 * @param int $id Optional. Post ID.
 * @param bool $leavename Optional, defaults to false. Whether to keep post name.
 * @param bool $sample Optional, defaults to false. Is it a sample permalink.
 * @return string
 */
function get_post_permalink($id = 0, $leavename = false, $sample = false)
{
    global $wp_rewrite;
    $post = get_post($id);
    if (is_wp_error($post)) {
        return $post;
    }
    $post_link = $wp_rewrite->get_extra_permastruct($post->post_type);
    $slug = $post->post_name;
    $draft_or_pending = isset($post->post_status) && in_array($post->post_status, array('draft', 'pending', 'auto-draft'));
    $post_type = get_post_type_object($post->post_type);
    if (!empty($post_link) && (!$draft_or_pending || $sample)) {
        if (!$leavename) {
            if ($post_type->hierarchical) {
                $slug = get_page_uri($id);
            }
            $post_link = str_replace("%{$post->post_type}%", $slug, $post_link);
        }
        $post_link = home_url(user_trailingslashit($post_link));
    } else {
        if ($post_type->query_var && (isset($post->post_status) && !$draft_or_pending)) {
            $post_link = add_query_arg($post_type->query_var, $slug, '');
        } else {
            $post_link = add_query_arg(array('post_type' => $post->post_type, 'p' => $post->ID), '');
        }
        $post_link = home_url($post_link);
    }
    return apply_filters('post_type_link', $post_link, $post, $leavename, $sample);
}