get_posts all posts code example
Example 1: get_posts category
$defaults_param = array(
'numberposts' => -1,
'post_type' => 'post',
'category' => 40 ,
'suppress_filters' => false
);
$get_featured_post = get_posts($defaults_param);
Example 2: get all posts
$args = array(
'numberposts' => 10,
'post_type' => 'book'
);
$latest_books = get_posts( $args );