问题描述
我的代码可以正常工作,但是问题是它只显示了我的自定义帖子类型“项目”中的2个帖子,而不是标准帖子中的1个。
这是我到目前为止在首页上所看到的:
<div class="content lg-grid">
<?PHP
// The 1st Query
$query1 = new WP_Query(array(
'posts_per_page' => 5,'post_type' => 'project'
));
// The 2nd Query
$query2 = new WP_Query(array(
'posts_per_page' => 1,'category' => 'art'
));
// The Main Query
$query3 = new WP_Query(array(
'post_type' => 'any','post__in' => $args
));
// Merge Arrays
$args = array_merge($query1->posts,$query2->posts);
$query3->post_count = count($query3->posts);
while ($query3->have_posts()) :
$query3->the_post();
?>
<div class="project-item">
<a href="<?PHP the_permalink(); ?>">
<img src="<?PHP the_post_thumbnail(); ?>" />
<h5 class="title"><?PHP the_title(); ?></h5>
</a>
</div>
<?PHP endwhile;
wp_reset_postdata(); ?>
</div>
解决方法
暂无找到可以解决该程序问题的有效方法,小编努力寻找整理中!
如果你已经找到好的解决方法,欢迎将解决方案带上本链接一起发送给小编。
小编邮箱:dio#foxmail.com (将#修改为@)