I am trying to:
Get the ancestor title of a taxonomy to display as an h1 at the top of my custom post archive (outside of the loop, so not repeated for each post).
For example I Have a hierarchical taxonomy called Locations with country at the top level:
Eg:
Denmark
> Aarhus
> Viborg
Sweden
> Stockholm etc...
I visited this URL:
hidden link (Unfortunately this is behind a login - but see my attached screengrab).
Using this template:
[wpv-layout-start]
[wpv-items-found]
<!-- wpv-loop-start -->
<wpv-loop>
<h1>[wpv-post-taxonomy type='location' format='name' id='$parent']</h1> <!-- How do I move this outside of this loop and only get it to display the Country name and not Denmark, Viborg --!>
[wpv-post-body view_template="Template for Practice with Maria"]
</wpv-loop>
<!-- wpv-loop-end -->
[/wpv-items-found]
[wpv-no-items-found]
<strong>[wpml-string context="wpv-views"]No items found[/wpml-string]</strong>
[/wpv-no-items-found]
[wpv-layout-end]
I'd like to see:
Just Denmark (taxonomy title) at the top of this page as an H1 and not have it repeated.
Instead, I have:
The entire hierarchy eg: Denmark, Viborg repeated for each post.
I've tried moving my h1 outside of the loop but nothing renders presumably because it needs the loop to orientate itself. But I don't know how to get this working.
Any pointers would be greatly appreciated.
Thanks,
Guy
Dear Guy,
If you are going to display the archive title of current archive page, please try with another shortcode [wpv-archive-title]:
https://toolset.com/documentation/user-guides/views-shortcodes/#wpv-archive-title
wpv-archive-title
This shortcode displays the title of the WordPress archive page.
Thanks Luo Yang,
That did the trick nicely.