Skip Navigation

[Gelöst] Display different content under the h1 heading using a conditional

Dieser Thread wurde gelöst. Hier ist eine Beschreibung des Problems und der Lösung.

Problem:

I'd like to display different content under the h1 heading using a conditional.

If case studies archive display:

Check out our case studies to see how we've helped our clients

If case studies taxonomy display:

Here are the case studies for our [wpv-archive-title]

Solution:

It is possible with shortcode [wpv-conditional], for example:

https://toolset.com/forums/topic/display-different-content-under-the-h1-heading-using-a-conditional/#post-1208186

Relevant Documentation:

https://toolset.com/documentation/user-guides/conditional-html-output-in-views/using-custom-functions-in-conditions/

This support ticket is created vor 5 Jahre, 1 Monat. 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.

No supporters are available to work today on Toolset forum. Feel free to create tickets and we will handle it as soon as we are online. Thank you for your understanding.

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 3 Antworten, has 2 Stimmen.

Last updated by guyA-2 vor 5 Jahre, 1 Monat.

Assisted by: Luo Yang.

Author
Artikel
#1208174

Thanks Luo,

That's got me moving forward again. I'm now using the Toolset WordPress archive as the archive for the case studies custom post type and taxonomy.

I'd like to display different content under the h1 heading using a conditional:
Is it possible to do something like this:
If case studies archive display:
Check out our case studies to see how we've helped our clients
If case studies taxonomy display:
Here are the case studies for our [wpv-archive-title]

I've been looking for the documentation on how to but don't know the syntax for this conditional.

Thanks for your support!

#1208186

Hello,

Yes, it is possible with shortcode [wpv-conditional], for example:
1) Dashboard-> Toolset-> Settings-> Front-end Content
in section "Functions inside conditional evaluations", add WordPress function name "is_post_type_archive"

2) Edit the WordPress archive "Case Studies Archive":
hidden link

In section "Loop Editor", display different text like this:

	[wpv-conditional if="(is_post_type_archive('case-study') eq 1)"]<h2>Check out our case studies to see how we've helped our clients</h2>[/wpv-conditional]
	[wpv-conditional if="(is_post_type_archive('case-study') eq 1)" evaluate="false"]<h2>[wpv-archive-title]</h2>[/wpv-conditional]

More help:
Using custom functions in conditions
https://toolset.com/documentation/user-guides/conditional-html-output-in-views/using-custom-functions-in-conditions/

#1208187

Hello,

Yes, it is possible with shortcode [wpv-conditional], for example:
1) Dashboard-> Toolset-> Settings-> Front-end Content
in section "Functions inside conditional evaluations", add WordPress function name "is_post_type_archive"

2) Edit the WordPress archive "Case Studies Archive":
hidden link

In section "Loop Editor", display different text like this:

	[wpv-conditional if="(is_post_type_archive('case-study') eq 1)"]<h2>Check out our case studies to see how we've helped our clients</h2>[/wpv-conditional]
	[wpv-conditional if="(is_post_type_archive('case-study') eq 1)" evaluate="false"]<h2>[wpv-archive-title]</h2>[/wpv-conditional]

More help:
Using custom functions in conditions
https://toolset.com/documentation/user-guides/conditional-html-output-in-views/using-custom-functions-in-conditions/

#1208188

Here's the solution provided by Toolset support to display conditional content for a custom post archive and a taxonomy archive of that same custom post.

Our custom post type slug is case-study and when we this condition is evaluated as false then we display the second line where we also insert the taxonomy archive title. So when we're on the taxonomy archive of our custom post we'll see something like: Here are the case studies for our "new website package" - new website package being our taxonomy archive title.

[wpv-conditional if="(is_post_type_archive('case-study') eq 1)"]<h2>Check out our case studies to see how we've helped our clients</h2>[/wpv-conditional]
[wpv-conditional if="(is_post_type_archive('case-study') eq 1)" evaluate="false"]<h2>Here are the case studies for our [wpv-archive-title]</h2>[/wpv-conditional]

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