【发布时间】:2016-05-19 18:29:09
【问题描述】:
我在管理员中创建了名为 testimonial 的自定义帖子类型,并在分类中创建了名为 sesseion 的分类。我在分类中有多个类别和子猫。我在主页上显示所有父猫和子猫。当用户点击子猫时需要显示该子类别的所有产品,当用户点击父类别时,它需要显示所有子类别列表。
我创建了一个名为“taxonomy-sesseion”的自定义模板。但是当我点击父目录和子目录时,它会重定向到该模板。我是否需要在同一个模板上添加一个条件以根据父目录显示差异列表和子猫?
这是在自定义分类模板上获取产品列表的代码。
$posts_array =
array(
'posts_per_page' => 16,
'post_type' => 'testimonials',
'tax_query' => array(
array(
'taxonomy' => 'sessions',
'field' => 'term_id',
'terms' => $term->term_id,
)
)
);
$query = new WP_Query($posts_array);
if ($query->have_posts()) :
while ($query->have_posts()) : $query->the_post();
$thumb_id = get_post_thumbnail_id($max_value[$i]->post_id);
$thumb_url = wp_get_attachment_image_src($thumb_id, 'large', true);
endwhile;
else:
echo "No Record";
endif;
【问题讨论】:
标签: wordpress