Skip Navigation

[Resolved] Need advice on displaying taxonomies

This support ticket is created 2 years, 4 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/Karachi (GMT+05:00)

Author
Posts
#2443411

Tell us what you are trying to do?

I have a custom post type (hoses) with a custom taxonomy (assets) which has 2 levels of hierarchy. The custom post type (hoses) is related to a another post type (clients)

I can set the hoses to show on the client template as belonging to that client however - I cannot do the same with the taxonomies as they appear to all clients.

I have tried creating the 'assets' taxonomy as custom post type instead (I have 2 levels of hierarchy). And have set the parent child relationships however when I come to create a new hose I can automatically select the Client the hose belongs to but I still have to select the custom post types for the 'assets' to create the relationships and the list of assets all appear again regardless of the client I'm posting for.

Is there anyway around this?

What is the link to your site?
hidden link

#2443895

Hi,

Thank you for contacting us and I'd be happy to assist.

To confirm, if I understand correctly, you'd like to show the related 'hoses' on the single 'client' page and also show the 'asset' taxonomy terms, attached to those related 'hoses'.

If that is correct, you'll need a view in the 'client' template, that will be set to show all the related 'hoses' posts. And, inside the loop of the view, you'll be able to show 'asset' terms from the current post in the loop.

I hope this helps and please let me know if you need any further assistance around this.

You're also welcome to share the link to an example 'client' post, in case you face some challenges in making this work.

regards,
Waqar

#2444055

Hi Waqar,

I understand that, but what about when I am creating 'hoses' via a form?
I need to be able to select the taxonomy the hose belongs to but only want the taxaonomies specific to that client to show.
How do I prevent that form showing other clients' assets?
Do I need to add the form within the related hose view on the client template?

Thanks

Vicky

#2444683

Thank you for sharing further details.

If the 'asset' taxonomy term selection for the 'hoses' need to be limited based on the related 'client', it would be better to attach the 'taxonomy' terms to the 'clients' post type too.

Here is how it will look:

1. The 'asset' taxonomy terms can be attached to both 'clients' and 'hoses' post types.

2. Suppose you have a total of 5 terms in the 'asset' taxonomy:
- Asset A
- Asset B
- Asset C
- Asset D
- Asset E

3. While creating a client post, let's say 'Client X', you'll assign these 3 asset terms, as the allowed ones:
- Asset A
- Asset C
- Asset E

4. Now, when creating a hose post, in the first step/form you'll specify which is the related client (in this case 'Client X'). Once the client is set, you'll show an edit form to edit the same host post with a generic 'multi select' or 'checkboxes' type field to select the allowed 'asset' terms.

The options of this field can be programmatically populated using a custom shortcode, that will get the related client post ID and then get its allowed/attached 'assets' terms so that only those terms are available for selection, for this hose post too.
(in this case only 'Asset A', 'Asset C' and 'Asset E')

And once the form is submitted, you can use the 'cred_save_data' hook, to process the selected term values from the generic field and attach them to the same hose post.
( ref: https://toolset.com/documentation/programmer-reference/cred-api/#cred_save_data )

I hope this structure/workflow makes sense and let me know if any step is not clear.