Skip Navigation

[Resolved] Display different content under the h1 heading using a conditional

This thread is resolved. Here is a description of the problem and solution.

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 5 years, 8 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/Hong_Kong (GMT+08:00)

This topic contains 3 replies, has 2 voices.

Last updated by guyA-2 5 years, 8 months ago.

Assisted by: Luo Yang.

Author
Posts
#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]