Skip Navigation

[Résolu] Retrieving a third level associated taxonomy

This support ticket is created Il y a 7 années. 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
- 7:00 – 14:00 7:00 – 14:00 7:00 – 14:00 7:00 – 14:00 7:00 – 14:00 -
- 15:00 – 16:00 15:00 – 16:00 15:00 – 16:00 15:00 – 16:00 15:00 – 16:00 -

Supporter timezone: Europe/London (GMT+00:00)

Marqué : ,

Ce sujet contient 5 réponses, a 2 voix.

Dernière mise à jour par Nigel Il y a 6 années et 12 mois.

Assisté par: Nigel.

Auteur
Publications
#599095
Screen Shot 2017-12-14 at 22.40.59.png

I have set up regions - associated to regions are events - associated to events are species (drawn from an event_species taxonomy)

For clarity

Region - Japan
Event - Winter Wildlife Photography Holiday in Japan
Species - Blakiston's Fish Owl, Red-crowned Crane, Snow Monkey, Steller's Sea Eagle, White-tailed Sea Eagle, Whooper Swan

on the region summary page I display a list of the events - each of these is listing the species - this is working fine

In the text at the top, I would like to insert a distinct list of all the species of the associated events - how do I obtain such a list?

I attach a screenshot of the Alaskan page - this is a great example as the summer events and the winter event have some of the same species, but some different - I would want the list to contain the species from all events, but in a distinct fashion - in the attached page, I would insert the distinct list in the sentence which reads 'to undertake photography of various species that are available within the region' - so it became 'to undertake photography of various species that are available within the region, including [list of linked species here] & more.'

#599225

Nigel
Supporter

Les langues: Anglais (English ) Espagnol (Español )

Fuseau horaire: Europe/London (GMT+00:00)

Hi David

I follow your objective in the last sentence.

I'm just unclear from your initial description, which is a taxonomy and which a post?

Region - taxonomy
Event - post
Species - taxonomy

Is that right? (Your question says third level associated taxonomy which confuses me.)

Or maybe region is a parent CPT so the Alaskan "page" is a single post.

(I need to know the context of where you will be displaying this text.)

#599226

Yes - you are pretty much correct

Region - taxonomy
Event - post
Species - taxonomy

... is correct - so I have a view for displaying the archive of a taxonomy - region - which displays the posts - events - belonging to that term - which in turn have associated taxonomies - species - it is the species for all associated posts that I want ... in a distinct list

#599344

Nigel
Supporter

Les langues: Anglais (English ) Espagnol (Español )

Fuseau horaire: Europe/London (GMT+00:00)

Hi David

It's not clear from what you wrote whether you have a custom archive made with Views for the region taxonomy archive, or whether you have created a View which does the same and is added to a page. (What you should avoid is creating a custom archive and adding a View to it instead of the archive output.)

In any case, what you want requires writing custom code, which will depend somewhat on whether this is an archive or a page with a View.

It will need to essentially replicate the archive or View query to get the same set of event posts, and the loop over them, getting the assigned species terms for each post in the loop and building up an array of terms once you have tested they are not duplicates and then using that to generate the result as a string.

If you try and tackle that and run into problems then let me know. It is outside our support policy to provide such code, though we try and help as much as possible, time permitting, so do ask if you have specific questions.

#599349

Ah that kind of confirms what I feared - I hoped that there was an easier way to achieve what I wanted

#599354

Nigel
Supporter

Les langues: Anglais (English ) Espagnol (Español )

Fuseau horaire: Europe/London (GMT+00:00)

Hi David

You've marked this as resolved.

Feel free to re-open it, and when I have some time next week I will give you more specific guidance.