Answer the question
In order to leave comments, you need to log in
How to display the category name of the created taxonomy in the template?
Hi guys! previously not associated with arbitrary fields, namely the ACF plugin, please tell me how to display the Category Name of the created Taxonomy in the template, I display them using
$thiscat = get_queried_object();
$thiscat_id = $thiscat->term_id;
$posts = get_field('list', 'category_' . $thiscat_id);
if( $posts ): ?>
foreach( $posts as $p )
$name_id = get_field('name_id', $p->ID);
название:<?php echo $name; ?>
Answer the question
In order to leave comments, you need to log in
<?php
/**
* @var $thiscat WP_Term
* @var $posts WP_Post[]
*/
$thiscat = get_queried_object();
if ($posts = get_field('list', $thiscat)) {
foreach ($posts as $post) {
$name_id = get_field('name_id', $post);
$terms = get_the_terms($post, $thiscat->taxonomy); // массив всех категорий поста
}
}
Didn't find what you were looking for?
Ask your questionAsk a Question
731 491 924 answers to any question