Skip to content
Read For Learn
Read For Learn
  • Database
    • Oracle
    • SQL
  • C
  • C++
  • Java
  • Java Script
  • jQuery
  • PHP
Read For Learn
  • Database
    • Oracle
    • SQL
  • C
  • C++
  • Java
  • Java Script
  • jQuery
  • PHP

Add Custom Taxonomy for Blog Meta Info

get_the_terms() is the function you need to get terms of a custom taxonomy associated to your post.

It is similar (but not identical) to get_the_category() for the default category taxonomy.

[Edited to answer the first comment below]

Adapting the code you have for categories, here’s how you can display either categories or terms:

<?php
    $categories = get_the_category();
    $separator = ", ";
    $output="";

    if ($categories) {

        foreach ($categories as $category) {

            $output .= '<a href="' . get_category_link($category->term_id) . '">' 
            . $category->cat_name . '</a>'  . $separator;

        }
        echo trim($output, $separator);
    }
    elseif ( $terms = get_the_terms( get_the_ID(), 'my-custom-taxonomy' ) ) {

        foreach ( $terms as $term ) {

            $output .= '<a href="' . get_term_link( $term, 'my-custom-taxonomy' ) . '">' 
            . $term->name . '</a>'  . $separator;

        }
        echo trim( $output, $separator );
    }
?>

Don’t forget to replace 'my-custom-taxonomy' (twice) with the actual slug for your taxonomy.

Note that by using this if/else structure, if a post has both a category and a term from the custom taxonomy, then only the category will show.
One can just change the elseif to just if in case they want both to be displayed in such case.

References:

  • get_the_terms()
  • get_term_link()
  • WP_Term class reference

Related Posts:

  1. How to add images to taxonomies?
  2. Custom Taxonomy and Tax_Query
  3. WordPress database error: [Not unique table/alias: ‘wp_postmeta’]
  4. How to modify the query in taxonomy-custom.php to sort term archives by a custom meta field?
  5. SQL QUERY needed to get POST category (taxonomy) ? – MUST be SQL statement
  6. How much faster is a tax query than a meta query?
  7. Use custom posts as taxonomy term meta replacement?
  8. Custom Taxonomy Meta Admin Column
  9. Is it possible to sort the post based on a custom field?
  10. How to show taxonomy meta on frontpage?
  11. Combine multiple custom user taxonomy in single url
  12. List Custom Taxonomy Values according to a Post Meta Value
  13. Advanced Tax Query
  14. Improving WP_Query performance for multiple taxonomies
  15. Taxonomy , subtaxonomy,child taxonomy of a product woocommerce
  16. How can I display all post IDs from the taxonomy?
  17. Get ID and slug from taxonomy object
  18. How to display custom taxonomy in multiple columns?
  19. get_the_terms() to show all custom taxonomies
  20. Single reusable value for post meta: Custom Taxonomy or Post Meta?
  21. Custom taxonomies making WP very slow – Way to fix?
  22. How to count the number of terms in a taxonomy
  23. Sorting taxonomy columns by meta value numeric
  24. Get Taxonmy Term ID For Current Post
  25. Display sub categories and their data of a taxonomy
  26. Insert form checkbox at bottom of taxonomy edit term page
  27. Advanced Query Logic With Multiple Taxonomies
  28. Display only first level children of my custom taxonomy categories
  29. Is it possible to get all term items from a custom taxonomy regardless of post attachment status?
  30. Changing stylesheet depending on custom taxonomy terms
  31. How do I taxonomy terms based on terms they are used alongside?
  32. Custom taxonomy [year] is directing to yearly archive
  33. Get posts by term slug only
  34. What is faster: custom taxonomy or serialized post-meta for db retrieval? (over 60,000 posts)
  35. How to show the a custom taxonomy term on single post metadata
  36. Taxonomies on custom taxonomies
  37. Is it possible to store Json data in post_meta and manipulate
  38. How to separate posts in loop?
  39. Search Tool only refreshes Page without showing results
  40. Creating terms vs custom post meta to save data?
  41. Getting associated taxonomies
  42. How to fetch the data from Advanced Custom post when we search specific keyword or field name related to the post?
  43. Creating conditional to display taxonomy term meta
  44. Does using custom taxonomy is more CPU efficient than using meta_data?
  45. How to add images to taxonomy terms? [duplicate]
  46. wp_query not resetting, last post hanging
  47. one post per term taxonomy
  48. Show only the sub-categories (and their content) of the current custom taxonomy with ‘taxonomy.php’
  49. Using Advanced Custom Fields Relationship Field to select a taxonomy term
  50. Custom arguments in WP_Query
  51. Count of posts by different parameters?
  52. check if a taxnomy queried in $wp_query?
  53. WP_Query tax_query – Show results if child has parent X
  54. WooCommerce custom taxonomy as meta?
  55. Query custom taxonomy for category including children
  56. Variable Not Working Inside is_author() Array
  57. Sort taxonomy page alphabetically by meta rather than default post date
  58. How to get related taxonomies based on a category with mysql query?
  59. Prioritise Pages over Taxonomy Term Root Archive, but not Taxonomy Term Child Archives
  60. Tracking the name of a custom taxonomy
  61. Add terms to a taxonomy archive from within the same taxonomy
  62. Is it possible to filter a taxonomy archive by other taxonomies that are on posts?
  63. Clean Taxonomy terms in new post type wordpress
  64. Fill New Taxonomies
  65. Convert post meta to custom taxonomy?
  66. Custom Taxonomies Archive Page 404
  67. Count tags for current post and save into custom meta field (and update it on post edit)
  68. WordPress taxonomy terms archive template help
  69. Is it possible to sort the post based on a custom field?
  70. Make relation of custom taxomies
  71. List active taxonomy terms
  72. taxonomy query on front page
  73. Custom post type term names with ampersand in the term name
  74. Looking for suggestions on creating simple database (Help!!)
  75. How do you search for a post by custom taxonomy?
  76. Next/Previous links in custom taxonomy, where item may belong to multiple terms
  77. How to query authors by custom taxonomy?
  78. get meta fields and taxonomy of any post type
  79. Where to put a migration script to switch post information?
  80. Update fields with post object and custom tax with wp_insert_post
  81. Adding a query var to taxonomy term archive – gets redirected to the other taxonomy archive page
  82. How can I show custom field according to taxonomy?
  83. How to get multiple Taxonomies not All Taxonomies?
  84. WordPress Taxonomy Menu
  85. Primary Taxonomy for Post
  86. Get taxonomy image for Toolset custom taxonomy through Toolset Views Shortcode
  87. wp_get_object_terms count on taxonomies within an category archive
  88. List posts grouped by children of a custom taxonomy
  89. Make custom post type display with custom taxonomy in url
  90. Hook to filter based on form value and insert term
  91. Complex Taxonomy scheme
  92. Querying posts globally based on custom taxonomy with its own taxonomymeta table
  93. Custom taxonomy with custom meta value is not sorting correctly (query returns the same value for orderby regardless of sort column click)
  94. Foreach for get_the_terms for hierarchical taxonomy don’t repeat Top Level Terms if contains multiple Second Level Terms
  95. How to handle custom taxonomy archive when no posts will have that taxonomy
  96. How can I list all the meta in a custom taxonomy?
  97. Using wp_query is it possible to orderby taxonomy?
  98. Advanced search form with filters for custom taxonomies and custom fields
  99. “tax_query” parameter not working with WP_Query
  100. How do I exclude a custom taxonomy from the post loop
Categories custom-taxonomy Tags advanced-taxonomy-queries, custom-taxonomy, post-meta, taxonomy-meta
How to translate WordPress Emails?
Restrict control in nav-menu for specific role

Recommended Hostings

Cloudways: Realize Your Website's Potential With Flexible & Affordable Hosting. 24/7/365 Support, Managed Security, Automated Backups, and 24/7 Real-time Monitoring.

FastComet: Fast SSD Hosting, Free Migration, Hack-Free Security, 24/7 Super Fast Support, 45 Day Money Back Guarantee.

Recent Added Topics

  • Bug in translation system: load_theme_textdomain() returns true, files are available and accessible but the language defaults to english
  • Custom Elementor controls not appearing in the widget Advanced tab using injection hooks
  • Get the name of the template/*html file used
  • Trying to Add Paging to Single Post Page
  • Sharing media files between live and staging servers
  • How to display the description of a custom post type in the dashboard?
  • Critical error on image display
  • Copying WP data and files into new install?
  • How to determine the DirectAdmin WordPress backup date?
  • How to get list of ALL tables in the database?
© 2026 Read For Learn
  • Database
    • Oracle
    • SQL
  • algorithm
  • asp.net
  • assembly
  • binary
  • c#
  • Git
  • hex
  • HTML
  • iOS
  • language angnostic
  • math
  • matlab
  • Tips & Trick
  • Tools
  • windows
  • C
  • C++
  • Java
  • javascript
  • Python
  • R
  • Java Script
  • jQuery
  • PHP
  • WordPress