Take the 2-minute tour ×
WordPress Development Stack Exchange is a question and answer site for WordPress developers and administrators. It's 100% free, no registration required.

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.

share|improve this question
add comment

1 Answer

up vote 2 down vote accepted

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:

http://codex.wordpress.org/Template_Tags/get_posts

share|improve this answer
    
Damn one space made a difference.. MAny thanks for help, its working perfect !:) Thanks and best regards, Arek K. –  Arkadiusz Kwiatkowski Apr 29 '13 at 8:36
1  
That happens to the best of us ;-) –  birgire Apr 29 '13 at 8:37
add comment

Your Answer

 
discard

By posting your answer, you agree to the privacy policy and terms of service.

Not the answer you're looking for? Browse other questions tagged or ask your own question.