0
I need to return the ID within this function:
$field = odin_get_term_meta( CATEGORY ID HERE, 'cattitulo' );
I tried it with get_term_meta() and get_terms() and nothing. I imagine it’s pretty simple, I don’t know where I’m going wrong.
0
I need to return the ID within this function:
$field = odin_get_term_meta( CATEGORY ID HERE, 'cattitulo' );
I tried it with get_term_meta() and get_terms() and nothing. I imagine it’s pretty simple, I don’t know where I’m going wrong.
1
You can use get_term_by() with the data you have of the category.
Ex.:
// Retorna o objeto da categoria Animais Fofinhos
$categoria = get_term_by( 'slug', 'animais-fofinhos', 'cattitulo' );
The first parameter accepted slug
, name
, id
or term_taxonomy_id
.
e depois:
$field = odin_get_term_meta( $categoria->term_id, 'cattitulo' );
Browser other questions tagged wordpress wordpress-theme
You are not signed in. Login or sign up in order to post.
Thanks Ricardo! But how to call the 'cute animals' automatically there in get_term_by ? (in my case it would be within the category page)
– Guilherme Sierra
@Guilhermesierra if you are in a category file, you can pick up the object in the Press
$wp_query->queried_object
or directly the id in$wp_query->queried_object_id
.– Ricardo Moraleida
Perfect! 100% Works. Thank you
– Guilherme Sierra
Cool @Guilhermesierra. If solved, mark the answer as chosen so people know.
– Ricardo Moraleida