0
I created a custom post type, and a taxonomy with the CTP UI plugin, but when it comes to listing in the loop the categories that are marked in the posts are not listed.
<?php
$args = array(
'post_type' => 'oferta',
'orderby' => 'menu_order',
'order' => 'ASC',
'posts_per_page' => -1
);
$loop = new WP_Query($args);
while ( $loop->have_posts() ) : $loop->the_post();
echo "<pre>";
var_dump(get_the_category($post->ID));
echo "</pre>";
?>
<?php endwhile; ?>
My return:
I managed to solve this problem:
– Junior Castro
I was able to solve this problem:
$categoria = get_the_terms($post->ID, 'ofertas_categoria');
var_dump($categoria[0]->name);
– Junior Castro