get_previous_post_link

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

WordPress Version: 6.2

/**
 * Retrieves the previous post link that is adjacent to the current post.
 *
 * @since 3.7.0
 *
 * @param string       $format         Optional. Link anchor format. Default '« %link'.
 * @param string       $link           Optional. Link permalink format. Default '%title'.
 * @param bool         $in_same_term   Optional. Whether link should be in the same taxonomy term.
 *                                     Default false.
 * @param int[]|string $excluded_terms Optional. Array or comma-separated list of excluded term IDs.
 *                                     Default empty.
 * @param string       $taxonomy       Optional. Taxonomy, if `$in_same_term` is true. Default 'category'.
 * @return string The link URL of the previous post in relation to the current post.
 */
function get_previous_post_link($format = '« %link', $link = '%title', $in_same_term = false, $excluded_terms = '', $taxonomy = 'category')
{
    return get_adjacent_post_link($format, $link, $in_same_term, $excluded_terms, true, $taxonomy);
}

WordPress Version: 5.7

/**
 * Retrieves the previous post link that is adjacent to the current post.
 *
 * @since 3.7.0
 *
 * @param string       $format         Optional. Link anchor format. Default '« %link'.
 * @param string       $link           Optional. Link permalink format. Default '%title'.
 * @param bool         $in_same_term   Optional. Whether link should be in a same taxonomy term. Default false.
 * @param int[]|string $excluded_terms Optional. Array or comma-separated list of excluded term IDs. Default empty.
 * @param string       $taxonomy       Optional. Taxonomy, if $in_same_term is true. Default 'category'.
 * @return string The link URL of the previous post in relation to the current post.
 */
function get_previous_post_link($format = '« %link', $link = '%title', $in_same_term = false, $excluded_terms = '', $taxonomy = 'category')
{
    return get_adjacent_post_link($format, $link, $in_same_term, $excluded_terms, true, $taxonomy);
}

WordPress Version: 4.9

/**
 * Retrieves the previous post link that is adjacent to the current post.
 *
 * @since 3.7.0
 *
 * @param string       $format         Optional. Link anchor format. Default '« %link'.
 * @param string       $link           Optional. Link permalink format. Default '%title'.
 * @param bool         $in_same_term   Optional. Whether link should be in a same taxonomy term. Default false.
 * @param array|string $excluded_terms Optional. Array or comma-separated list of excluded term IDs. Default empty.
 * @param string       $taxonomy       Optional. Taxonomy, if $in_same_term is true. Default 'category'.
 * @return string The link URL of the previous post in relation to the current post.
 */
function get_previous_post_link($format = '« %link', $link = '%title', $in_same_term = false, $excluded_terms = '', $taxonomy = 'category')
{
    return get_adjacent_post_link($format, $link, $in_same_term, $excluded_terms, true, $taxonomy);
}

WordPress Version: 4.6

/**
 * Retrieves the previous post link that is adjacent to the current post.
 *
 * @since 3.7.0
 *
 * @param string       $format         Optional. Link anchor format. Default '« %link'.
 * @param string       $link           Optional. Link permalink format. Default '%title%'.
 * @param bool         $in_same_term   Optional. Whether link should be in a same taxonomy term. Default false.
 * @param array|string $excluded_terms Optional. Array or comma-separated list of excluded term IDs. Default empty.
 * @param string       $taxonomy       Optional. Taxonomy, if $in_same_term is true. Default 'category'.
 * @return string The link URL of the previous post in relation to the current post.
 */
function get_previous_post_link($format = '« %link', $link = '%title', $in_same_term = false, $excluded_terms = '', $taxonomy = 'category')
{
    return get_adjacent_post_link($format, $link, $in_same_term, $excluded_terms, true, $taxonomy);
}

WordPress Version: 4.5

/**
 * Get previous post link that is adjacent to the current post.
 *
 * @since 3.7.0
 *
 * @param string       $format         Optional. Link anchor format.
 * @param string       $link           Optional. Link permalink format.
 * @param bool         $in_same_term   Optional. Whether link should be in a same taxonomy term.
 * @param array|string $excluded_terms Optional. Array or comma-separated list of excluded term IDs.
 * @param string       $taxonomy       Optional. Taxonomy, if $in_same_term is true. Default 'category'.
 * @return string The link URL of the previous post in relation to the current post.
 */
function get_previous_post_link($format = '« %link', $link = '%title', $in_same_term = false, $excluded_terms = '', $taxonomy = 'category')
{
    return get_adjacent_post_link($format, $link, $in_same_term, $excluded_terms, true, $taxonomy);
}

WordPress Version: 4.1

/*
 * Get previous post link that is adjacent to the current post.
 *
 * @since 3.7.0
 *
 * @param string       $format         Optional. Link anchor format.
 * @param string       $link           Optional. Link permalink format.
 * @param bool         $in_same_term   Optional. Whether link should be in a same taxonomy term.
 * @param array|string $excluded_terms Optional. Array or comma-separated list of excluded term IDs.
 * @param string       $taxonomy       Optional. Taxonomy, if $in_same_term is true. Default 'category'.
 * @return string The link URL of the previous post in relation to the current post.
 */
function get_previous_post_link($format = '« %link', $link = '%title', $in_same_term = false, $excluded_terms = '', $taxonomy = 'category')
{
    return get_adjacent_post_link($format, $link, $in_same_term, $excluded_terms, true, $taxonomy);
}

WordPress Version: 4.0

/*
 * Get previous post link that is adjacent to the current post.
 *
 * @since 3.7.0
 *
 * @param string       $format         Optional. Link anchor format.
 * @param string       $link           Optional. Link permalink format.
 * @param bool         $in_same_term   Optional. Whether link should be in a same taxonomy term.
 * @param array|string $excluded_terms Optional. Array or comma-separated list of excluded term IDs.
 * @param string       $taxonomy       Optional. Taxonomy, if $in_same_term is true. Default 'category'.
 * @return string
 */
function get_previous_post_link($format = '« %link', $link = '%title', $in_same_term = false, $excluded_terms = '', $taxonomy = 'category')
{
    return get_adjacent_post_link($format, $link, $in_same_term, $excluded_terms, true, $taxonomy);
}

WordPress Version: 3.8

/*
 * Get previous post link that is adjacent to the current post.
 *
 * @since 3.7.0
 *
 * @param string       $format         Optional. Link anchor format.
 * @param string       $link           Optional. Link permalink format.
 * @param bool         $in_same_term   Optional. Whether link should be in a same taxonomy term.
 * @param array|string $excluded_terms Optional. Array or comma-separated list of excluded term IDs.
 * @param string       $taxonomy       Optional. Taxonomy, if $in_same_term is true. Default 'category'.
 * @return string
 */
function get_previous_post_link($format = '« %link', $link = '%title', $in_same_cat = false, $excluded_terms = '', $taxonomy = 'category')
{
    return get_adjacent_post_link($format, $link, $in_same_cat, $excluded_terms, true, $taxonomy);
}

WordPress Version: 3.7

/*
 * Get previous post link that is adjacent to the current post.
 *
 * @since 3.7.0
 *
 * @param string $format Optional. Link anchor format.
 * @param string $link Optional. Link permalink format.
 * @param bool $in_same_cat Optional. Whether link should be in same category.
 * @param string $excluded_categories Optional. Excluded categories IDs.
 * @return string
 */
function get_previous_post_link($format = '« %link', $link = '%title', $in_same_cat = false, $excluded_categories = '')
{
    return get_adjacent_post_link($format, $link, $in_same_cat, $excluded_categories, true);
}