Answers for "get 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
1

get taxonomy name in singhle post

// RETRIVE TERM SLUG ( for single.php or template-part )

$terms = get_the_terms( $post->ID, 'your-taxonomy' );
if ( !empty( $terms ) ){
    // get the first term
    $term = array_shift( $terms );
    echo $term->slug;
}
Posted by: Guest on May-13-2020
0

get term id by post id

INSIDE TAXONOMY PAGES
$term      = get_queried_object();
$term_id   = $term->term_id;
Posted by: Guest on January-02-2021

Code answers related to "get taxonomy by post id"

Browse Popular Code Answers by Language