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?
Use
get_posts()
or filter'pre_get_posts'
on the front page.Sample code for
get_posts()
: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.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.