query lastet wp

Solutions on MaxInterview for query lastet wp by the best coders in the world

showing results for - "query lastet wp"
Élie
05 Mar 2020
1<?php
2
3    // The Query
4    $next_args = array(
5                    'post_type' => '<your_post_type>',
6                    'post_status' => 'publish',
7                    'posts_per_page'=>2,
8                    'order'=>'DESC',
9                    'orderby'=>'ID',
10                    );
11
12    $the_query = new WP_Query( $args );
13
14    // The Loop
15    if ( $the_query->have_posts() ) {
16        $not_in_next_three = array();
17        while ( $the_query->have_posts() ) {
18            $the_query->the_post();
19            //your html here for latest 2
20            $not_in_next_three[] = get_the_ID();
21        }
22
23    } else {
24        // no posts found
25    }
26    /* Restore original Post Data */
27    wp_reset_postdata();
28