Get custom category of a custom post type

0

I created a custom post type, and a taxonomy with the CTP UI plugin, but at the time of listing in the loop the categporias 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:

    
asked by anonymous 29.12.2016 / 21:05

1 answer

1

Hello. I was able to do using this formula

 <?php
    $taxonomia = "sua taxonomia";
    $terms = get_terms($taxonomy, array(
        "orderby"    => "count",
        "hide_empty" => false,
        ));

    foreach($terms as $term) {
    // faça alguma coisa
    }

Or you can adapt to the while you have wordpress post.

    
19.03.2018 / 15:14