我创建了两种自定义帖子类型,每种类型都有几个类别。我需要运行一个查询,在标记的不同部分返回两种帖子类型的结果(“问题”、“解决方案”)。如果不重写依赖于每个“提示”的 ID 的大量 jquery,我就无法更改我的标记。我尝试了各种循环但没有成功。有人可以给我一些见解吗?WordPress循环如下:
<?php get_header(); ?>
<?php
$args = array(
'post_type' => array('problems', 'solutions'),
'tax_query' => array(
array(
'taxonomy' => 'category',
'field' => 'slug',
'terms' => array('my-category')
)
)
);
$loop = new WP_Query( $args );
$tipID = array('tip-1','tip2','tip-3','tip-4','tip-5');
$tipID_count = count($tipID);
$tipID_index = 0;
while($loop->have_posts()) : $loop->the_post();
?>
<div class="tooltip" <?php $k = $tipID_index % $tipID_count; echo "id=#$tipID[$k]"; $tipID_index++; ?>>
<dl>
<dt><a href="" class="imageText">1</a></dt>
<!--///////problems\\\\\\\-->
<dd class="problem">
<span class="close pull_right"><a href="" class="imageText">close</a></span>
...do stuff
<div class="tip-foot"></div>
</dd>
<!--///////solutions\\\\\\\-->
<dd class="solution">
<span class="close pull_right"><a href="" class="imageText">close</a></span>
...do stuff
<div class="tip-foot"></div>
</dd>
</dl>
</div>
<?php endwhile; ?>