Answers for "get primary taxonomy by post id"

PHP
4

wordpress get taxonomy of a post

<?php $term_obj_list = get_the_terms( $post->ID, 'taxonomy_name' ); ?>
Posted by: Guest on July-09-2020
0

wordpress get data from post type and taxonomy id

$posts_array = get_posts(
    array(
        'posts_per_page' => -1,
        'post_type' => 'fabric_building',
        'tax_query' => array(
            array(
                'taxonomy' => 'fabric_building_types',
                'field' => 'term_id',
                'terms' => $cat->term_id,
            )
        )
    )
);

foreach ($posts_array as $post) {
	print_r($post);
	echo $post->ID;
}
Posted by: Guest on June-18-2021

Code answers related to "get primary taxonomy by post id"

Browse Popular Code Answers by Language