I am trying to create a function which adds additional custom data fields to my taxonomy pages, I have found this plugin which add this capability. Now I can get the saving the custom data works fine.. however trying to get the metadata on edit form pages is another story..

I've followed the documentation which says to use the following line..

get_term_meta($term_id, $key, $single) 

However I am unable to get this to work.. I have to manually enter the term_id like so..

$term_meta = get_term_meta('36', '', true); 

.. in order for it to work. Can someone tell me what code I would need for php get the term_id?

3 Answers

You can use this function to do the debug

$term = get_term_by('slug', get_query_var( 'term' ), get_query_var( 'taxonomy' ) ); print_r ($term); 

Thanks

1

yes true.

$idObj = get_category_by_slug(post_type); $id1 = $idObj->term_id; 

If you are using any WordPress inbuilt function, then you need write the objname->subkey.

Okay so I found the problem

I had to use $term_id->term_id instead of just $term_id

Your Answer

Sign up or log in

Sign up using Google Sign up using Facebook Sign up using Email and Password

Post as a guest

By clicking “Post Your Answer”, you agree to our terms of service, privacy policy and cookie policy