<?php
$terms = get_terms(array(
'taxonomy' => array('catalog'), // название таксономии с WP 4.5
'orderby' => 'name',
'order' => 'ASC',
'hierarchical' => false,
'hide_empty' => 0,
'parent' => 0
));
?>
<div class="section section_catalog">
<div class="section__inner container">
<div class="grid grid_4 grid_add-spaces grid_center grid_categories">
<?php foreach ($terms as $term) { ?>
<div class="grid__item">
<a href="<?= get_term_link($term->term_id, 'catalog'); ?>" class="catalog-box catalog-box_category catalog-box_<?= $term->term_id; ?>">
<div class="catalog-box__img-wrap">
<div class="catalog-box__img"></div>
</div>
<div class="catalog-box__info">
<div class="catalog-box__title" title="<?= $term->name; ?>">
<div class="catalog-box__title-inner">
<?= $term->name; ?>
</div>
</div>
<div class="catalog-box__text">
<?= str_replace(',', ', ', $term->description); ?>
</div>
</div>
</a>
</div>
<?php } ?>
</div>
</div>
</div>
$terms = get_terms(array(
'taxonomy' => array('catalog'),
'orderby' => 'name',
'order' => 'ASC',
'hierarchical' => false,
'hide_empty' => 0,
'parent' => get_queried_object_id() // Возвращает ID текущей категории
));
?>
<div class="section section_catalog">
<div class="section__inner container">
<div class="grid grid_4 grid_add-spaces grid_center grid_categories">
<?php foreach ($terms as $term) { ?>
<div class="grid__item">
<a href="<?= get_term_link($term->term_id, 'catalog'); ?>" class="catalog-box catalog-box_category catalog-box_<?= $term->term_id; ?>">
<div class="catalog-box__img-wrap">
<div class="catalog-box__img"></div>
</div>
<div class="catalog-box__info">
<div class="catalog-box__title" title="<?= $term->name; ?>">
<div class="catalog-box__title-inner">
<?= $term->name; ?>
</div>
</div>
<div class="catalog-box__text">
<?= str_replace(',', ', ', $term->description); ?>
</div>
</div>
</a>
</div>
<?php } ?>
</div>
</div>
</div>
title="<?= esc_attr($term->name); ?>">
'hierarchical' => true,
Он должен вывести дочерние термины с соблюдением иерархии<?php
$taxonomy = ‘team_type’;
$orderby = ‘name’;
$show_count = 0;
$pad_counts = 0;
$hierarchical = 1;
$title = »;
$empty = 1;
$args = array(
‘taxonomy’ => $taxonomy,
‘orderby’ => $orderby,
‘show_count’ => $show_count,
‘pad_counts’ => $pad_counts,
‘hierarchical’ => $hierarchical,
‘title_li’ => $title,
‘hide_empty’ => $empty
);
?>
<?php $all_categories = get_categories( $args );
//print_r($all_categories);
foreach ($all_categories as $cat) {
if($cat->category_parent == 0) {
$category_id = $cat->term_id;
// print_r($cat->term_id);
?>
<div class=»b-drop wow fadeInUp down»>
<div class=»b-drop__alsus down-toggle»><span class=»typo-uiuri»><?php echo $cat->name ?></span></div>
<div class=»b-drop__body down-body»>
<div class=»cn-cols-row cn-gutter-h-30 wow-delay cn-mb-70 cn-mb-30—sm»>
<?php
global $wp_query;
$wp_query = new WP_Query(array(
‘post_type’ => ‘team’,
‘posts_per_page’ => ’10’,
‘tax_query’ => array(
array(
‘taxonomy’ => ‘team_type’,
‘field’ => ‘term_id’,
‘terms’ => $cat->term_id
)
)
// ‘paged’ => get_query_var(‘paged’) ?: 1
));
while( have_posts() ){
the_post(); ?>
<div class=»cn-w-3_12 cn-w-6_12—sm cn-mb-30 cn-mb-30—sm»>
<div class=»cn-cols-row cn-gutter-h-30 procurement-block»>
<div class=»cn-w-6_12 cn-w-12_12—lg»>
<a href=»<?php the_permalink(); ?>»>
<img class=»s-procurement__img» src=»<?php echo get_the_post_thumbnail_url(); ?>» alt=»»>
</a>
</div>
<div class=»cn-w-6_12 cn-w-12_12—lg»>
<div>
<h5 class=»procurement-t»><a href=»<?php the_permalink(); ?>»><?php the_title(); ?></a></h5>
<p class=»deadline»><?php the_field( ‘deadline’ ); ?></p>
<div class=»text cn-mb-30″><?php echo wp_trim_words( get_the_content(), 40, ‘…’ );?></div>
<a class=’btn_procurement btn_last_news cn-m-0′ href=»<?php the_permalink(); ?>»><?php _e(‘Learn more’,’eu4′); ?></a>
</div>
</div>
</div>
</div>
<?php } wp_reset_query(); ?>
</div>
</div>
</div>
<?php } } ?>