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 am building an "advent calendar" for a client and they are wanting a combination of specific pages and custom posts appearing on the front page, in a specific order.

Things that need to be retrieved are Title, Excerpt (or Content up to ), Permalink, Featured Image and Custom Fields...

What's the best way to go about retrieving these from the database? A custom SQL query? Some sort of Walker? A complicated Menu?

share|improve this question

Use get_posts() or filter 'pre_get_posts' on the front page.

Sample code for get_posts():

$my_post_array = get_posts( 
    array ( 
        'post_type' => array ( 'post', 'custom_type' ) 

foreach ( $my_post_array as $post )
    // do something awesome …

There are also parameters for a custom order by meta fields and so on. A filter on 'pre_get_posts' can do the same and more. It is just not as easy to read.

share|improve this answer
up vote 0 down vote accepted

I ended up specifying the posts, pages and custom posts in a custom Navigation menu, and created a Custom Walker to output the right information.

share|improve this answer

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.