Browse: Home / Snippets /

Get all course IDs

Contents


Snippet #

function learndash_get_all_course_ids() {
	$query_args = array(
		'post_type'			=>	'sfwd-courses',
		'post_status'		=>	'publish',
		'fields'			=>	'ids',
		'orderby'			=>	'title',
		'order'				=>	'ASC',
		'nopaging'			=>	true	// Turns OFF paging logic to get ALL courses
	);

	$query = new WP_Query( $query_args );
	if ( $query instanceof WP_Query) {
		return $query->posts;
	}
}