i'm trying to order multiples post types in a page my solution below is working but the posts are not showing by type after type exactly
<?php $args = array_merge( $wp_query->query,
array( 'post_type' =>array( 'editorial','video','portfolio' ),'posts_per_page=-1','orderby'=>'post_type') );
}
query_posts( $args );
$postType='';
if (have_posts()) : while (have_posts()) : the_post();
$PT = get_post_type( $post->ID );
if($postType != $PT){
$postType = $PT;
echo '<p class="clearfix"><h1>All posts of type : '.$postType.'</h1></p>';
}
?>
<?php
if($postType == 'editorial'){ ?>
<?php echo $postType; ?>
<?php }elseif($postType == 'video'){ ?>
<?php echo $postType; ?>
<?php }elseif($postType == 'portfolio'){
<?php echo $postType; ?>
}
?>
and it output like that:
All posts of type : editorial
editorial
editorial
editorial
All posts of type : video
video
video
All posts of type : editorial //problem
editorial
All posts of type : portfolio
portfolio
portfolio
portfolio
portfolio
thank you in advance
According to the Codex,
post_type
isn't one of the allowed values for theorderby
parameter.One way around your problem would be to use the
posts_orderby
filter, something like this:FWIW, I'd suggest changing
'posts_per_page=-1'
to'posts_per_page' => -1
to be consistent with your other arguments.