You must use $post and global $post.


global $post;
$args = array( 'numberposts' => 5, 'offset'=> 1, 'category' => 1 );
$myposts = get_posts( $args );
foreach( $myposts as $post ){
setup_postdata($post);
echo the_title();
}
wp_reset_postdata();

Leave a Reply

Your email address will not be published. Required fields are marked *