How to return a Category ID in WordPress?

0

I need to return the ID within this function:

$ field = odin_get_term_meta (CATEGORY ID HERE, 'cattitle');

I tried with get_term_meta () and get_terms () and nothing. I guess it's pretty simple, I do not know where I'm going wrong.

    
asked by anonymous 18.02.2017 / 17:41

1 answer

1

You can use get_term_by () with the data you have in the category.

Ex.:
// Retorna o objeto da categoria Animais Fofinhos
$categoria = get_term_by( 'slug', 'animais-fofinhos', 'cattitulo' );

The first parameter accepts slug , name , id or term_taxonomy_id .

e depois:
$field = odin_get_term_meta( $categoria->term_id, 'cattitulo' );
    
19.02.2017 / 00:02