Tribe__Repository::nth( $n )
{@inheritdoc}
Source
File: src/Tribe/Repository.php
public function nth( $n ) {
$per_page = (int) Tribe__Utils__Array::get_in_any( array(
$this->query_args,
$this->default_args,
), 'posts_per_page', get_option( 'posts_per_page' ) );
if ( - 1 != $per_page && $n > $per_page ) {
return null;
}
$query = $this->build_query();
$return_id = 'ids' === $query->get( 'fields', '' );
$i = absint( $n ) - 1;
$query->set( 'fields', 'ids' );
$ids = $query->get_posts();
if ( empty( $ids[ $i ] ) ) {
return null;
}
return $return_id ? $ids[ $i ] : $this->format_item( $ids[ $i ] );
}