WordPress Development Stack Exchange is a question and answer site for WordPress developers and administrators. Join them; it only takes a minute:

Sign up
Here's how it works:
  1. Anybody can ask a question
  2. Anybody can answer
  3. The best answers are voted up and rise to the top

I have custom post type (Events) with 6 events.

$posts = get_posts( array('post_type' => 'events') );
echo '<!-- ';
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
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
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 Lysobey Feb 24 '12 at 0:07

Your Answer


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.