Tutorial by Examples

Creating a separate instance of the WP_Query object is easy: $query_args = array( 'post_type' => 'post', 'post_per_page' => 10 ); $my_query = new WP_Query($query_args); if( $my_query->have_posts() ): while( $my_query->have_posts...
get_posts() is a wrapper for a separate instance of a WP_Query object. The returned value is an array of post object. global $post; $args = array( 'numberposts' => 5, 'offset'=> 1, 'category' => 1 ); $myposts = get_posts( $args ); foreach( $myposts as $post ) : ...

Page 1 of 1