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 custom post type (Events) with 6 events.

$posts = get_posts( array('post_type' => 'events') );
echo '<!-- ';
print_r($posts);
echo ' -->';

This code shows the 5 with the most recent published date.

I should perhaps note that we have been changing the published date as a hacky sort of way to change the post display order. I'm not sure when the event started being omitted, or if this is related, but there it is.

Does anyone have any insight as to why this kind of thing would happen? Thanks.

share|improve this question
1  
I wouldn't recommend using the publishing date as the date for the event's occurrence - it would be better (and easier) to save this as post meta or stored in a custom table. –  Stephen Harris Feb 23 '12 at 23:44
add comment

1 Answer

up vote 2 down vote accepted

The default nmber of posts returned is 5.

To return more than 5 posts use:

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

Or for all of them:

$posts = get_posts( array('post_type' => 'events', 'numberposts' => -1) );

More info about get_posts http://codex.wordpress.org/Template_Tags/get_posts

share|improve this answer
    
well I feel silly, thanks –  Zach L Feb 24 '12 at 0:07
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.