[wp-hackers] showposts/posts_per_page bug?

Simon Blackbourn piemanek at gmail.com
Sat Dec 4 22:08:04 UTC 2010

i have a custom post type called 'project', with eight published posts. if i
do the following query...

$projects = get_posts( array(
                        'order'     => 'asc',
                        'orderby'   => 'title',
                        'post_type' => 'project',
                        'posts_per_page' => -1

...only five results are returned. if i change it to...

$projects = get_posts( array(
                        'order'     => 'asc',
                        'orderby'   => 'title',
                        'post_type' => 'project',
                        'showposts' => -1

...it correctly returns all eight posts.

according to the codex page[1], showposts was deprecated in favour of
posts_per_page, so surely these two queries should return exactly the same

i tried adding 'nopaging' => true to the first query but it still only
returns five posts. what's also odd is that five doesn't relate to any of my
site's settings (i have 10 in the 'reading' options), so i've no idea where
it comes from.

i've reproduced this exact same behaviour on two sites with all other
plugins & filters disabled, so there does certainly seem to be a bug (or
maybe bugs) in there, but i'm not sure what exactly.

anyone else encountered this?

i couldn't find a trac ticket, let me know if there is one already,
otherwise i'll open one if this is definitely a bug.



More information about the wp-hackers mailing list