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.
WordPress Development Stack Exchange is a question and answer site for WordPress developers and administrators. It only takes a minute to sign up.
Sign up to join this communityHow 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.