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 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

2 Answers 2

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

 
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.