I am currently working in a project in wordpress.
Here i have to get all posts from two custom post types namely pt1, pt2.
But here i want to display posts with random post type(pt1, pt2).
Example)
I want to display first post from pt1, next from pt2 and again pt1 and next pt2 and so on...
How can i do this. Any help? This is the code:
$args = array(
$args = array(
'posts_per_page' => 5,
'orderby' => 'post_date',
'order' => 'DESC',
'post_type' => array('pt1', 'pt2'),
'post_status' => 'publish'
);
$posts = get_posts( $args );
$num=1;
foreach($posts as $post) {
if( $num % 2 == 0 )
echo $post->post_title.$post->post_type;
else
echo $post->post_title.$post->post_type;
$num++;
}