How can I get parent category ID in single page template, outside of loop?
$category = get_the_category();
echo $category[0]->term_id;
The code isn't working outside loop correctly.
How can I get parent category ID in single page template, outside of loop?
$category = get_the_category();
echo $category[0]->term_id;
The code isn't working outside loop correctly.