David Alsbright
David Alsbright

Reputation: 1565

Wordpress Loop for pages AND posts

I know it's possible to have multiple post loops on the same page, what I'm trying to achieve is having a single loop that will grab all pages and posts and then display them in chronological order.

So far I've only been able to loop for one or the other using WP_Query, two separate loops isn't an option as I need to be able to sort the output by date.

Does anyone have any experience doing something similar? Any advice on where to start would be greatly appreciated.

Upvotes: 0

Views: 258

Answers (1)

David
David

Reputation: 5937

try:

$args = array(
'post_type' => array('carmarket', 'bikemarket') // or 'post', 'page' etc whatever you want

);
$query = new WP_Query( $args );

ref: http://codex.wordpress.org/Class_Reference/WP_Query

Upvotes: 1

Related Questions