WordPress как на ладони
Недорогой хостинг для сайтов на WordPress: wordpress.jino.ru
функция не описана

get_adjacent_post_rel_link() WP 2.8.0

Retrieves the adjacent post relational link.

Can either be next or previous post relational link.

Хуки из функции
Возвращает

Строку/null. The adjacent post relational link URL.

Использование

get_adjacent_post_rel_link( $title, $in_same_term, $excluded_terms, $previous, $taxonomy );
$title(строка)
Link title format.
По умолчанию: '%title'
$in_same_term(true/false)
Whether link should be in a same taxonomy term.
По умолчанию: false
$excluded_terms(массив/строка)
Array or comma-separated list of excluded term IDs.
По умолчанию: ''
$previous(true/false)
Whether to display link to previous or next post.
По умолчанию: true
$taxonomy(строка)
Taxonomy, if $in_same_term is true.
По умолчанию: 'category'

Список изменений

С версии 2.8.0 Введена.

Код get_adjacent_post_rel_link() WP 5.5.3

<?php
function get_adjacent_post_rel_link( $title = '%title', $in_same_term = false, $excluded_terms = '', $previous = true, $taxonomy = 'category' ) {
	$post = get_post();
	if ( $previous && is_attachment() && $post ) {
		$post = get_post( $post->post_parent );
	} else {
		$post = get_adjacent_post( $in_same_term, $excluded_terms, $previous, $taxonomy );
	}

	if ( empty( $post ) ) {
		return;
	}

	$post_title = the_title_attribute(
		array(
			'echo' => false,
			'post' => $post,
		)
	);

	if ( empty( $post_title ) ) {
		$post_title = $previous ? __( 'Previous Post' ) : __( 'Next Post' );
	}

	$date = mysql2date( get_option( 'date_format' ), $post->post_date );

	$title = str_replace( '%title', $post_title, $title );
	$title = str_replace( '%date', $date, $title );

	$link  = $previous ? "<link rel='prev' title='" : "<link rel='next' title='";
	$link .= esc_attr( $title );
	$link .= "' href='" . get_permalink( $post ) . "' />\n";

	$adjacent = $previous ? 'previous' : 'next';

	/**
	 * Filters the adjacent post relational link.
	 *
	 * The dynamic portion of the hook name, `$adjacent`, refers to the type
	 * of adjacency, 'next' or 'previous'.
	 *
	 * @since 2.8.0
	 *
	 * @param string $link The relational link.
	 */
	return apply_filters( "{$adjacent}_post_rel_link", $link );
}