I want to add a back button that goes to the parent category of the actual single post that the user is viewing. How can I do that?
<h2 class="link"><a href="#">Return</a></h2>
Thank you.
|
I want to add a back button that goes to the parent category of the actual single post that the user is viewing. How can I do that?
Thank you. |
|||||
|
|
You can use get_the_category() and return the first result as in the example. Technically you could have several parent categories so you need to deal with this separately or expect that the first element of the array is always the right parent category. |
|||||
|
This code gives output:
Important Link: get_the_category |
|||
|
|