Answer the question
In order to leave comments, you need to log in
The id from the taxonomy is not correctly set. How to fix?
I am making a filter for cards and each of the filters has its own taxonomy, which is called the same as the name of the filter.
Here is an example of two blocks ( They are all the same, they just have different names and did not insert everything ):
<div class="advanced-filter_item filter-disactive simple-filter_item">
<p class="rus">Язык обучения</p>
<p class="eng hide">language of education</p>
<?php
$categories = get_terms('language', 'orderby=name&hide_empty=0');
if($categories){
echo '<select id="language"><option value="card-item">Любой</option>';
foreach ($categories as $cat){
echo "<option value='language-{$cat->term_id}'>{$cat->name}</option>";
}
echo '</select>';
}
?>
</div>
<div class="advanced-filter_item filter-disactive simple-filter_item">
<p class="rus">Программа</p>
<p class="eng hide">Program</p>
<?php
$categories = get_terms('program', 'orderby=name&hide_empty=0');
if($categories){
echo '<select id="program"><option value="card-item">Любая</option>';
foreach ($categories as $cat){
echo "<option value='program-{$cat->term_id}'>{$cat->name}</option>";
}
echo '</select>';
}
?>
</div>
<?php $query = new WP_Query( 'post_type=program-card' ); ?>
<?php while ( $query->have_posts()):$query->the_post(); ?>
<div class="card-item level-<?php the_field('card_level-id'); ?> direction-<?php the_field('card_direction-id'); ?> university-<?php the_field('card_university-id'); ?> program-<b><?php
$categories = get_terms('program', 'orderby=name&hide_empty=0');
if($categories){
echo "{$cat->term_id}";
}
?> language-<?php the_field('card_language-id'); ?></b>">
// Здесь какой-то контент (Не важно, что внутри, важны классы выше)
</div>
<?php endwhile; ?>
<?php wp_reset_postdata(); ?>
Answer the question
In order to leave comments, you need to log in
Didn't find what you were looking for?
Ask your questionAsk a Question
731 491 924 answers to any question