Get Posts

Last Updated: August 30, 2021

You can use the following code to get regular or custom posts in WP. This will return an array of posts

$args = array(
  'numberposts' => 10,
  'post_type'   => 'book'
);
 
$latest_books = get_posts( $args );