How to Get All Post in WordPress Query

How to Get All Post in WordPress Query

To get all the post in returned WordPress query results, you have to put: 'posts_per_page' => -1 in query arguments. For example:

$all_posts = get_posts( array(
	'post_type'	   => 'post', // e. g. custom_post_type
	'orderby'          => 'post_date',
        'order'            => 'DESC',
	'posts_per_page'   => -1,
) );
Share this Post