I've been looking everywhere but can't find any way to make this works. I am using the Taxonomy Metadata plugin and I am trying to display the custom metadata created. For this I use: get_term_meta($term_id, 'my_metadata', TRUE);. The problem is that I can't find a way to get the term_id. I am in a template page inside the loop. Here is what I have tried:

$term = get_term_by('name', 'name', 'custom_taxonomy');
$termid = $term->term_id;
$metadata = get_term_meta($termid, 'my_metadata', TRUE);

But it's not working, it just returns: Trying to get property of non-object for the term_id.

Could you help me please?

Thank you!

  • 1
    get_term_by isn't finding the term, either the name or the taxonomy you are passing is incorrect.
    – Milo
    Commented Jun 28, 2014 at 18:37

1 Answer 1


Alright, I have found a way. If it can be useful for someone here is how I solved it:

$terms = get_the_terms( $post->ID , 'custom_taxonomy' );
if($terms) {
foreach( $terms as $term ) {
    $term_id = $term->term_id;

Then you can use $term_id in your expression.

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service and acknowledge you have read our privacy policy.

Not the answer you're looking for? Browse other questions tagged or ask your own question.