Yoast\WP\SEO\Actions

Indexables_Page_Action::get_least_linked()publicYoast 1.0

Gets the least linked posts.

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

Хуков нет.

Возвращает

Массив. The most linked posts as an array.

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

$Indexables_Page_Action = new Indexables_Page_Action();
$Indexables_Page_Action->get_least_linked( $limit );
$limit(int) (обязательный)
The maximum amount of results to return.

Код Indexables_Page_Action::get_least_linked() Yoast 19.11

public function get_least_linked( $limit ) {
	// where_not_equal needs the set to check against not to be empty.
	$least_linked_ignore_list = $this->options_helper->get( 'least_linked_ignore_list', [] );
	$ignore_list              = empty( $least_linked_ignore_list ) ? [ -1 ] : $least_linked_ignore_list;

	$least_linked = $this->query()
		->select_many( 'id', 'object_id', 'object_sub_type', 'permalink', 'breadcrumb_title', 'incoming_link_count' )
		->where_not_in( 'id', $ignore_list )
		->order_by_asc( 'incoming_link_count' )
		->limit( $limit )
		->find_many();

	$least_linked = \array_map( [ $this->indexable_repository, 'ensure_permalink' ], $least_linked );
	return \array_map(
		function ( $indexable ) {
			$output = $indexable;
			if ( $indexable->incoming_link_count === null ) {
				$output->incoming_link_count = 0;
			}
			return $output;
		},
		$least_linked
	);
}