[polylang]count posts using ‘get_term_by’
-
I use polylang plugin.
I created taxonomy(ex.my_taxonommy) and created a term (ex.my_term) for ‘my_taxonomy’.
and then I added a term(ex.my_term_en) as a translation for ‘my_term’.Now I want to count posts which terms are ‘my_term_en’.
I used ‘get_term_by’ like:
$count = get_term_by(‘slug’,’my_term_en’,’my_taxonomy’);
$cnt = $count->count;But ‘get_term_by’ returns bool(false).
I treid,
$count = get_term_by(‘slug’,’my_term’,’my_taxonomy’);
and this could be OK.
I know ‘my_term’ is default language.How can I do this?
Thanks for your help.
Viewing 3 replies - 1 through 3 (of 3 total)
Viewing 3 replies - 1 through 3 (of 3 total)
- The topic ‘[polylang]count posts using ‘get_term_by’’ is closed to new replies.