Change site style→

style-1 style-2
  1. nazenani
  2. >
  3. >
  4. >
  5. Get taxonomy data.

Get taxonomy data.

Taxonomy is category in wordpress, but don’t equal “category” in post.
!Refer Theory: Post type and taxonomy!

The code below show how to get taxonomy data. “tax_query” was used in the script.


“get_query_var()” gets data in WP_Query. “term” is information in taxonomy.
get_term_by() gets all Term data from database.

$slug has all taxonomy information, $term gets $slug(value) of slug(field) in works_tax(taxonomy).


‘tax_query’ is a parameter using to get data interacting WP_Query. It has some keys and values in array and filter data which will get in WP_Query.

  • ‘taxonomy’: set taxonomy.
  • ‘terms’:taxonomy terms.
  • ‘field’: data source field in taxonomy.
  • ‘operation’: operator to test. IN=include.


WordPress codex:Class Reference/WP_Query


Fields with * is required.

go to related tags archive?