Skip Navigation

[Resolved] Conditional display of taxonomy data

This support ticket is created 5 years, 6 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 – 12:00 9:00 – 12:00 9:00 – 12:00 9:00 – 12:00 9:00 – 12:00 -
- 13:00 – 18:00 13:00 – 18:00 13:00 – 18:00 14:00 – 18:00 13:00 – 18:00 -

Supporter timezone: America/Jamaica (GMT-05:00)

Tagged: 

This topic contains 10 replies, has 4 voices.

Last updated by simonF-5 5 years, 6 months ago.

Assisted by: Shane.

Author
Posts
#1305941

I have a taxonomy in which I have one general item, and multiple others that are more particular. I would like to display the general item in a separate line when it's present, but not have a skipped line when it's not present. That is, display something like this:

Label: General Item
item 1, item 2, item 3

But when the general taxonomy item is not checked, I'd like the template to display the other items in line, eg.:

Label: item 1, item 2, item 3

Is this possible?

#1306033

Shane
Supporter

Languages: English (English )

Timezone: America/Jamaica (GMT-05:00)

Hi John,

The general Item is the Taxonomy correct? I'm assuming Item 1, Item 2, Item 3 are the posts?

Please let me know.

Thanks,
Shane

#1306569

They are all taxonomies. Maybe it will be easier to explain with the specifics. The site is for students going for a year abroad. The issue arises because:
(1) some universities will accept them for an exchange only in some subjects, e.g. just physics or law
(2) others offer a university-wide exchange,
(3) yet others offer university-wide, but only some subjects are available in English.

I'd like 'University-Wide', 'Physics', 'Law', Subject X' ... to be all part of the same 'Subjects' taxonomy. The reason for this is that I would like them to work as filters on a search page, allowing students to choose whether they're looking for their specific subject, or a university-wide exchange.

And then:

In case (1), I'd like the site to display (that's easy):
Subjects: Law, Physics, Subject X

In case (2), I'd like the site to display (that's easy):
Subjects: University-Wide

In case (3), I'd like the site to display (this is the only problematic one):
Subjects: University-Wide
Law, Physics, Subject X

Currently in case (3) it displays:
Subjects: Law, Physics, Subject X, University-Wide

So basically I need a conditional of the shape: 'if post has category 'University-Wide', then display 'University-wide' first, then skip to the next line and display the remaining categories.

I hope this is clearer! Is this possible using the [wpv-conditional]? If not, would there be some other way? Thank you!

#1306641

Alternatively, this could be approached from another way. I could make 'University-Wide' to not be a part of the taxonomy, and instead be a custom checkbox field. But then what I would need is that whenever a student selects a subject in the search filter, the search displays all posts with this subject category, AND all posts with the 'University-Wide' checkbox ticked.

This would actually be a preferable option, now that I think about it! Is that possible?

#1307113

Hi, Shane is on public holiday today and will return tomorrow to continue assisting you with this ticket.

#1307977

Shane
Supporter

Languages: English (English )

Timezone: America/Jamaica (GMT-05:00)

Hi John,

Ok, I see the issue now. Seeing that University wide is a taxonomy then we could sort it alphabetically given that this will be ok for you.

I'm assuming you're using the [wpv-post-taxonomy] shortcode, then you can just use the attribute order='desc' to sort it.

Please let me know if this helps.
Thanks,
Shane

#1308213

Thanks! I don't think this will work, because it'll still display as part of the same line. If I have, say, Business and Zoology listed, whichever way I do the alphabetical order, 'University-wide' will always end up in the middle. And I want to make sure it's always visible as first.

What do you think of the other approach I mentioned?

#1308227

Shane
Supporter

Languages: English (English )

Timezone: America/Jamaica (GMT-05:00)

Hi John,

The approach of having the checkbox for it is good but if you display it you will need to add the shortcode for it before the taxonomy shortcode.

Also on the frontend filter it will be a single checkbox by itself.

Is this ok for you to just have the single filter for this ?

Please let me know.
Thanks,
Shane

#1311561

Hi Shane,

Not really - as I mentioned, the whole point of this is to allow users to select specific subjects or 'University-wide' from a single dropdown. I take it from your reply that this simply won't be possible? Is there no way to merge the two filters into one?

#1311653

Shane
Supporter

Languages: English (English )

Timezone: America/Jamaica (GMT-05:00)

Hi John,

In this case no it won't be possible since for your scenario it will be 2 different fields, so you wouldn't be able to combine them.

Thanks,
Shane

#1316103

OK, thanks! It's a shame, I think this would be a useful functionality. Please note it as a dev suggestion!
Thanks for your help!