How to show taxonomy terms from wordpress database?

Solution One:

get_terms() – Retrieve the terms in a given taxonomy or list of taxonomies.

You can fully inject any customizations to the query before it is sent, as well as control the output with a filter.

The ‘get_terms’ filter will be called when the cache has the term and will pass the found term along with the array of $taxonomies and array of $args. This filter is also called before the array of terms is passed and will pass the array of terms, along with the $taxonomies and $args.

get_terms returns an array of objects. You cannot echo an array, if you do, you will just get Array(). What you can do is print_r($array) or var_dump($array) to see the data it contains.

$taxonomy = 'shirt';
$args=array(
  'hide_empty' => false,
  'orderby' => 'name',
  'order' => 'ASC'
);
$tax_terms = get_terms( $taxonomy, $args );
foreach ( $tax_terms as $tax_term ) {
    echo $tax_term->name;
}

Solution Two:

You can use the function called get_taxonomies() in order to query out the taxonomy that you need.

Syntax:

 <?php get_taxonomies( $args, $output, $operator ) ?>

Example:

This example uses the ‘object’ output to retrieve and display the taxonomy called ‘genre’:

<?php 
$args=array(
  'name' => 'genre'
);
$output="objects"; // or names
$taxonomies=get_taxonomies($args,$output); 
if  ($taxonomies) {
  foreach ($taxonomies  as $taxonomy ) {
    echo '<p>' . $taxonomy->name . '</p>';
  }
}  
?>