我想显示与当前类别相关的所有分类法。
我可以显示它,但是如果分类法与多个类别相关联,那么它只会显示一个分类法。
我有多个类别具有不同的分类法,如果一个类别具有多个分类法,则下面的代码仅显示一个分类法结果。
我想显示与当前类别相关的所有分类法。
代码还调用了一些ACF字段,例如图像,符号,扇区和页面链接
<?php
$custom_query = new WP_Query(
array(
'cat' => get_query_var('cat'),
'parent' => -1,
'order' => 'DESC',
'orderby' => 'count',
'hide_empty' => false,
)
);
if ($custom_query->have_posts()) :
while ($custom_query->have_posts()) : $custom_query->the_post();
$posttags = get_the_tags();
if ($posttags) {
foreach($posttags as $tag) {
$all_tags[] = $tag->term_id;
}
}
endwhile;
endif;
if ($posttags) {
// Start the loop through the terms
foreach ($posttags as $tag) {
// Get acf field Name
$tag_link = get_term_link( $tag );
$symbol = get_field('symbol');
$sectors = get_field('sectors');
$page_link = get_field('page_link');
$image = get_field('profile_image', $tag );
$url = $image['url'];
$title = $image['title'];
$alt = $image['alt'];
// which size?
$size = 'large';
$thumb = $image['sizes'][ $size ];
}
$all_categories = get_tags( $get_featured_cats );
$j = 1;
foreach ($all_categories as $cat) {
$cat_id = $cat->tag_id;
$cat_link = get_category_link( $cat_id );
}
?>
<ul class="directory-box col-md-4">
<li>
<div class="col-md-12" style="border: 1px solid #f5a8ac;padding: 0 !important;">
<img src="<?php echo $thumb; ?>" alt="<?php echo $alt; ?>" title="<?php echo $title; ?>" class="img-responsive"/>
<p style="text-align: center;font-size: 18px;font-weight: bold;"><i class="fa fa-line-chart" aria-hidden="true"></i> <i><?php echo the_field('symbol', $tag) ?></i></p>
</div>
<div class="col-md-12">
<h4><a href="<?php echo the_field('page_link', $tag) ?>"><?php echo $tag->name; ?></a></h4>
<p><?php echo $tag->description; ?></p>
<p><i class="fa fa-bookmark-o" aria-hidden="true"></i> <strong><?php echo the_field('sectors', $tag) ?></strong></p>
<p><i class="fa fa-pencil-square-o" aria-hidden="true"></i> <a href="<?php echo get_term_link($tag); ?>">Profile Posts</a></p>
<a href="<?php echo the_field('page_link', $tag) ?>" class="link-pro" style="text-align: center;
display: block;margin: 20px auto 5px;width: 150px;float: none;">Profile Link</a>
</div>
</li>
</ul>
<?php } ?>