I have a few categories with the same name [some of them are sub-categories]. And I want to get an array of ID’s for certain cattegory name.
I tried this:
$term = get_term_by('name', $cat_name, 'category');
but it seems that get_term_by()
returns only the first term that match the query.
Use
get_terms()
, which usesWP_Term_Query
under the hood. For a full list of all the available parameters check out the documentation forWP_Term_Query::__construct
get_cat_ID( $cat_name )
can do the trick! Example:MORE Detail!