Need to pull parent category and slug – only pulling daughter category

Question

I am tweaking a theme for my friend, and I am using the following:

<?php $category = get_the_category(); ?> <h3 class="omc-blog-two-cat"><a href="<?php echo home_url(); echo ('/category/'.$category[0]->slug); ?>"><?php echo $category[0]->cat_name; ?></a></h3>

This gives website.com/category/categoryslug/, displaying the daughter category slug but I also want the parent category included as well. Ideally as website.com/category/parentcategory/daughtercategory

How can I achieve this? Many thanks 😀

0
, Obsidian 4 years 2020-03-25T16:52:20-05:00 0 Answers 86 views 0

Leave an answer

Browse
Browse