Get Child Category only
I am using this code to retrieve category:
$post_id = get_the_ID(); $countries = get_the_terms( $post_id, 'country' ); $fcountry = $countries->slug;
However this sometimes retrieves the parent category of the countries (in our scenario the continent). How could I make this to always output the child category (i.e. the country)?
02 years 2020-12-16T08:10:25-05:00 2020-12-16T08:10:25-05:00 0 Answers 7 views 0
Leave an answer