Answers for "custom taxonomy (register new post and get them from db)"

PHP
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 custom post type taxonomy value

<?php $terms = wp_get_post_terms( $query->post->ID, array( 'country', 'subject' ) ); ?>
<?php foreach ( $terms as $term ) : ?>
<p><?php echo $term->taxonomy; ?>: <?php echo $term->name; ?></p>
<?php endforeach; ?>
Posted by: Guest on September-30-2021

Code answers related to "custom taxonomy (register new post and get them from db)"

Browse Popular Code Answers by Language