Есть несколько способов сделать это, но, учитывая, что вы знаете, что такое slug, самый простой способ - это использовать функцию get_term_by
.
Вы можете использовать заголовок, чтобы получить все детали термина, используя get_term_by
, включая имя. Это отдельный от вашего WP_Query, поэтому вы можете использовать его вне l oop.
<?php
// set up variables for the slug & taxonomy - then this can all be changed dynamically if you need to
$term_slug = "novedades";
$term_taxonomy = "tipo_de_cuadro";
// Pass the slug & taxonomy to get_term_by to get all the term details
$term = get_term_by('slug', $term_slug, $term_taxonomy);
$term_name = $term->name; // get the name from the term
$args = array(
'post_type' => 'cuadros',
'post_per_page' => 4,
'tax_query' => array(
array(
'taxonomy' => $term_taxonomy,
'field' => 'slug',
'terms' => $term_slug
),
),
);
$postQuery = new WP_Query($args);
if ( $postQuery->have_posts()) : ?>
<div class="product-carousel">
<!-- you can use your term_name variable here before you set the_post -->
<h2><?php echo $term_name; ?></h2>
<!-- [do stuff....] -->
</div>
<?php endif; ?>