Number of displayed posts

I have tried many things to solve this problem.

So I have a plugin which displays projects assigned to users in a widget. It displays projects as posts. The problem is that it only displays 5 projects on the page.

I am sending a code which display posts:

$projects = get_posts(array('post_type' => 'projects'));

One guy told me to change it to

$projects = get_posts(array('post_type' => 'projects', 'number posts' => 10));

which should help but it didnt.

Anyone have idea how to solve it ? I can send whole code if it’s needed.

Solutions Collecting From Web of "Number of displayed posts"

The WordPress function get_posts() supports:

'posts_per_page'  => 10,
'numberposts'     => 10,

so you should use:

$projects = get_posts(array('post_type' => 'projects', 'numberposts' => 10));

instead of

$projects = get_posts(array('post_type' => 'projects', 'number posts' => 10));

If you want to show all posts, you can use

'posts_per_page'  => -1

You can read more about this in the WordPress Codex: