我正在尝试在一个页面中订购多个帖子类型 我下面的解决方案正在运行,但帖子没有按类型显示
<?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; ?>
}
?>
它的输出是这样的:
所有类型的帖子:社论
社论
社论
社论
所有类型的帖子:视频
视频
视频
所有类型的帖子:社论//问题
社论
所有类型的帖子:投资组合
文件夹
文件夹
文件夹
文件夹
先感谢您