Is it possible to bring the latest, penultimate and before penultimate post?

Hello. On my page there are 3 units which need to get last 3 post. In the first block of the last (the newest), in the second block, the third block third-last. They are all from the same category. By ID is also impossible (the newest published). Is it possible?

Thank you.
June 26th 19 at 14:25
3 answers
June 26th 19 at 14:27
RUB this crap and shame so - ernesto_Reilly1 commented on June 26th 19 at 14:30
Hi. Thanks for the answer. Please write more, I'm new to php - miles.Maye commented on June 26th 19 at 14:33
this came from Microsoft?
PS I did Not think that the adherents of the MSSQL sitting here - laila.Zbonc commented on June 26th 19 at 14:36
: What? Talking about the EP. Not even on the database. - ernesto_Reilly1 commented on June 26th 19 at 14:39
: crap sitting in your head. - Leora commented on June 26th 19 at 14:42
June 26th 19 at 14:29
Is it possible?

Layout - is the answer to the solution of the problem.

And if you need to make a selection on criteria - smoke matches: wp_query, get_posts, pre_get_posts.
Thanks for the tip, I'm going to read - ernesto_Reilly1 commented on June 26th 19 at 14:32
June 26th 19 at 14:31
Read about the WP_QUERY class
$query = new WP_Query( array(
 'post_type' => 'post', // page, post, product..
 'posts_per_page' => 3, // -1 = all posts
 'order' => 'DESC', // or ASC
 ) );

if ( $query->have_posts() ) {
 echo '<ul>';
 while ( $query->have_posts() ) { $query->the_post();
 echo '<li><a href="'.get_permalink().'">' . get_the_title() . '</a></li>';
 echo "</ul>";

post_type - entry(post) pages(page) or product(product)..
post_per_page = If you don't add the pagination control displays the names of the 3 entries..
order = take the records from the end(DESC) or from start(ASC)

Find more questions by tags WordPressPHP