WordPress taxonomy in details

In WordPress world, the word taxonomy is quite popular. The taxonomy is quite powerful for filtering or searching content in WordPress. The relational database of WordPress has a complete flow of terms and taxonomies.

To support the growing requirements of the project we may need to add custom taxonomy. We may also need to display those terms of the custom taxonomy.

How to get all terms of a custom taxonomy?

Let say we have a custom taxonomy called post_type, then we can get all the terms using the following query:

$terms = get_terms([
    'taxonomy' => $taxonomy,
    'hide_empty' => false,