简体   繁体   中英

Get the terms from a custom taxonomy without posts

What I am asking is, is there a built-in function that gets the the result of the following mysql query? get_terms() seems to get only the terms that are assigned eg to a post and not the whole list.

select 
    name
from
    wordpress.wp_terms
where
    term_id in (select 
            term_id
        FROM
            wordpress.wp_term_taxonomy
        where
            taxonomy = 'custome_taxonomy')

I think you have a misunderstanding about get_terms and don't know the purpose of the arguments within get_terms

By default, all terms without posts are hidden, here is the argument

'hide_empty'    => true, 

To retrieve terms without posts, you'll need to pass false to the hide_empty argument, like this

$terms = get_terms( 'hide_empty=false' );

The technical post webpages of this site follow the CC BY-SA 4.0 protocol. If you need to reprint, please indicate the site URL or the original address.Any question please contact:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM