Skip Navigation

[Resolved] Displaying a taxonomy title outside of the loop

This support ticket is created 7 years, 5 months ago. There's a good chance that you are reading advice that it now obsolete.

This is the technical support forum for Toolset - a suite of plugins for developing WordPress sites without writing PHP.

Everyone can read this forum, but only Toolset clients can post in it. Toolset support works 6 days per week, 19 hours per day.

Sun Mon Tue Wed Thu Fri Sat
- 9:00 – 13:00 9:00 – 13:00 9:00 – 13:00 9:00 – 13:00 9:00 – 13:00 -
- 14:00 – 18:00 14:00 – 18:00 14:00 – 18:00 14:00 – 18:00 14:00 – 18:00 -

Supporter timezone: Asia/Hong_Kong (GMT+08:00)

This topic contains 2 replies, has 2 voices.

Last updated by guyA-2 7 years, 5 months ago.

Assisted by: Luo Yang.

Author
Posts
#457206
screengrab-1.jpg

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

#457479

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.

#457948

Thanks Luo Yang,

That did the trick nicely.

This ticket is now closed. If you're a WPML client and need related help, please open a new support ticket.