Answers for "get custom taxonomy in wordpress"

PHP
0

show all terms of a custom taxonomy

$terms = get_terms( array(
  'taxonomy' => 'taxonomy_name_or_slug',
  'hide_empty' => true,
) );
foreach ($terms as $term){
  echo $term->slug;
  echo $term->name;
  echo "<br><br>";
}
Posted by: Guest on July-20-2020
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 current taxonomy

$term = get_term_by( 'slug', get_query_var( 'term' ), get_query_var( 'taxonomy' ) );
echo $term->name; // will show the name
echo $term->slug; // will show the slug
Posted by: Guest on October-21-2020
0

how to display the taxonomy image in wordpress

<?php

// get the current taxonomy term
$term = get_queried_object();

// vars
$image = get_field('cat_image', $term);

?>

<img src="<?php echo $image['url']; ?>" />
Posted by: Guest on November-16-2020

Code answers related to "get custom taxonomy in wordpress"

Browse Popular Code Answers by Language