Skip Navigation

[Gelöst] Taxonomy condition display

This support ticket is created vor 5 Jahren, 11 Monaten. 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.

Heute stehen keine Supporter zur Arbeit im Werkzeugsatz-Forum zur Verfügung. Sie können gern Tickets erstellen, die wir bearbeiten werden, sobald wir online sind. Vielen Dank für Ihr Verständnis.

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)

Dieses Thema enthält 10 Antworten, hat 2 Stimmen.

Zuletzt aktualisiert von Akhil vor 5 Jahren, 11 Monaten.

Assistiert von: Nigel.

Author
Artikel
#1151740

Hi Nigel

You gave me some codes here:https://toolset.com/forums/topic/filter-search-with-taxonomy-conditional/#post-1143006

i have set of operating hours fields, but i wan it to display only for certain taxonomies . will be using this in content template

Can i use the above shortcode still ? i tried this its valid but no output.

 [wpv-conditional if="('[taxonomy ='taxonomy' ]' eq 'Eat & Drink' )" debug="true"]
eat drink
[/wpv-conditional]
#1151820

Nigel
Supporter

Sprachen: Englisch (English ) Spanisch (Español )

Zeitzone: Europe/London (GMT+00:00)

Hi Dee

The shortcode I gave you was to be used on taxonomy archives.

The context is important, and it is important not to confuse taxonomies and the terms of a given taxonomy.

So, you are using this on a content template, so the context here will be displaying a post.

Posts may have certain taxonomies available to them, and from the available taxonomies they may or may not have individual terms assigned to them.

So what exactly do you want to test?

If, for the current post being displayed, a particular term of a specified taxonomy is assigned to that post?

(That's sort of a trick question, as it is really the only thing you can test in this context, but I wanted you to confirm that.)

#1151830

Hi Nigel,

i am using it here: versteckter Link

eat-and-drink is the slug of taxonomy i assume. .

i need to display field using taxonomy conditional. . on the page click the clock icon, i need to set it to display only if taxonomy = eat-and-drink OR business.

#1151845

Nigel
Supporter

Sprachen: Englisch (English ) Spanisch (Español )

Zeitzone: Europe/London (GMT+00:00)

OK, so the context is the taxonomy archive, meaning you can use the custom taxonomy shortcode.

You would use it something like this, in that case:

[wpv-conditional if="( '[taxonomy output='slug']' eq 'eat-drink' ) OR ( '[taxonomy output='slug']' eq 'business' )"]
<p>Output what you want</p>
[/wpv-conditional]

I'm using slugs here because there is less chance of a mistake with the text name such as "Eat and drink" instead of "Eat and Drink". You can see the slugs on the page where you enter and edit terms for the taxonomy (as a sub-menu item for the custom post type they are assigned to).

#1151846

My issue is resolved now. Thank you Nigel !

#1151865

Hi Nigel,
the 'slug' is not good for the main archive page . is there anything else i can do ?

you can see here the clock icon is missing here versteckter Link but here its fine versteckter Link

#1151954

Nigel
Supporter

Sprachen: Englisch (English ) Spanisch (Español )

Zeitzone: Europe/London (GMT+00:00)

The problem there is that you are not on a term archive page, you are on an archive for the entire taxonomy, so the custom shortcode cannot know which taxonomy term we are 'on' because there is none.

So there you are looking at what terms are assigned to the posts themselves.

That case is covered by this example: https://toolset.com/documentation/user-guides/conditional-html-output-in-views/displaying-taxonomies-conditionally/#specific

#1152036

Thanks, i have came up with this. both working ,

[wpv-conditional if="( has_term('eat-drink', 'directory-category', null) eq '1' )" ]
eat1 [/wpv-conditional]
      
[wpv-conditional if="('[wpv-post-taxonomy type='directory-category' format='slug' ]' eq 'eat-drink' )" debug="0true"]
eat 2 
[/wpv-conditional]

could you guide me for targeting more then 1 tax slug pls. thanks.

#1152047
#1152127

Nigel
Supporter

Sprachen: Englisch (English ) Spanisch (Español )

Zeitzone: Europe/London (GMT+00:00)

I showed an example of that above: https://toolset.com/forums/topic/taxonomy-condition-display/#post-1151845

You can do the same but with the wpv-post-taxonomy shortcode, using the OR condition.

#1153601

My issue is resolved now. Thank you!