Yoast\WP\SEO\Presentations

Indexable_Date_Archive_Presentation::generate_rel_prev()publicYoast 1.0

Generates the rel prev.

Метод класса: Indexable_Date_Archive_Presentation{}

Хуков нет.

Возвращает

Строку. The rel prev value.

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

$Indexable_Date_Archive_Presentation = new Indexable_Date_Archive_Presentation();
$Indexable_Date_Archive_Presentation->generate_rel_prev();

Код Indexable_Date_Archive_Presentation::generate_rel_prev() Yoast 20.0

public function generate_rel_prev() {
	if ( $this->pagination->is_rel_adjacent_disabled() ) {
		return '';
	}

	$current_page = \max( 1, $this->pagination->get_current_archive_page_number() );
	// Check if there is a previous page.
	if ( $current_page === 1 ) {
		return '';
	}
	// Check if the previous page is the first page.
	if ( $current_page === 2 ) {
		return $this->current_page->get_date_archive_permalink();
	}

	return $this->pagination->get_paginated_url( $this->current_page->get_date_archive_permalink(), ( $current_page - 1 ) );
}