recent post query wordpress

Solutions on MaxInterview for recent post query wordpress by the best coders in the world

showing results for - "recent post query wordpress"
Montserrat
29 Aug 2017
1 <?php 
2            $recent_args = array(
3                'post_type' => 'post type name',
4                'posts_per_page' => 4,
5                'orderby'        => 'date',
6                'order'          => 'DESC'
7            );      
8            $recent_posts = new WP_Query( $recent_args );
9            
10            if( $recent_posts->have_posts() ) {
11        	    while( $recent_posts->have_posts() ) : $recent_posts->the_post(); 
12                
13                the_title();
14                
15                endwhile;
16            
17    		} 
18    		else {
19    	    	echo "There is no posts";
20    	    }
21    
22    	    wp_reset_postdata();   
23 ?>