List terms of taxonomies related to post_type specific Wordpress

0

Hello, I have to list all the terms of 4 taxonomies, however they have to belong to a specific post type!

For example, I have the following information:

post_type (graduation, postgraduate)  taxonomy (place, unit)

I've already researched everything that is place, and I could not find what I'm looking for ..

I want to list all terms that have post marked as taxonomy: local and that belongs to graduation; I tried get_terms, wp_get_post_terms, did several tests and loops, and none brought me the list I need.

If you can help me, thank you very much! Note taxonomies are related to all post types.

    
asked by anonymous 15.02.2018 / 17:34

2 answers

0

Good people, for those who have the same doubt that I one day, I managed to solve using a very interesting function:

link

And I did another method that I posted here on the site:

link

    
19.02.2018 / 11:17
0

I think you need to do the consutla for tax_query

$posts = get_posts(
    array(
        'posts_per_page' => -1,
        'post_type' => 'graduacao',
        'tax_query' => array(
            array(
                'taxonomy' => 'nome-taxonomia', //o nome da sua taxonomia
                'field' => 'term_id', // id do campo da taxonomia...
                'terms' => 'local', // o termo da taxonomia
            )
        )
    )
);

I'm considering that location is an item within a taxonomy called nome-taxonomia

    
15.02.2018 / 17:39