Skip Navigation

[Resolved] Conditional elements don’t show anymore

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

Problem:
How to check specific taxonomy term is assigned to post or not using [wpv-conditional] shortcode

Solution:
You can use the CONTAINS() function with [wpv-conditional] shortcode to check if specific taxonomy term is assigned to post or not.

You can fine proposed solution in this case with the following reply:
=> https://toolset.com/forums/topic/conditional-elements-dont-show-anymore/#post-2064159

Relevant Documentation:
=>https://toolset.com/documentation/legacy-features/views-plugin/displaying-taxonomies-conditionally/#specific

This support ticket is created 3 years, 7 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
- 10:00 – 13:00 10:00 – 13:00 10:00 – 13:00 10:00 – 13:00 10: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/Kolkata (GMT+05:30)

This topic contains 5 replies, has 2 voices.

Last updated by dominiqueM-3 3 years, 7 months ago.

Assisted by: Minesh.

Author
Posts
#2064041
after-update.jpg
before-update.jpg

Hello,

I'm using Toolset for a site that proposes content for members.
Memberships, members and restricted content are managed by MemberPress.
In the content type archive I've created for restricted content, posts are displaying excerpt and you need to login to see all the content. If user is not logged in, a message is displayed to explain that the article is only available for members.
I've made a test to display different message per taxonomy term.

After updating Toolset plugins, my conditional elements added to the custom post archive don't show anymore.

Below is the code used to test the taxonomy of post (Toolset shortcode) and if the user is logged in (memberpress shortcode):
[wpv-conditional if=" ( ( '[wpv-post-taxonomy type="collection-publication" format="name"]' eq 'Sentinelle' ) ) " ]
[mepr-hide rules="12316"]
<div class="excerpt-allow">
[wpv-post-excerpt length="200" more="…"]</div>
<div class="for-subscribers sentinelle">
<p class="alert">Réservé aux abonnés Sentinelle</p>
<p class="links">
Je m'abonne
</p>
</div>
[/mepr-hide]
[mepr-show rules="12316"]
<div class="excerpt-allow">
[wpv-post-excerpt length="200" more="…"]</div>
<p class="read-more">
Lire la suite
</p>
[/mepr-show]
[/wpv-conditional]
[wpv-conditional if=" ( ( '[wpv-post-taxonomy type="collection-publication" format="name"]' eq 'Focus' ) ) " ]
[mepr-hide rules="12317"]
<div class="excerpt-allow">
[wpv-post-excerpt length="200" more="…"]</div>
<div class="for-subscribers focus">
<p class="alert">Réservé aux abonnés Focus</p>
<p class="links">
Je m'abonne
</p>
</div>
[/mepr-hide]
[mepr-show rules="12317"]
<div class="excerpt-allow">
[wpv-post-excerpt length="200" more="…"]</div>
<p class="read-more">
Lire la suite
</p>
[/mepr-show]
[/wpv-conditional]

Could you please provide some help?

Best regards

#2064093

Minesh
Supporter

Languages: English (English )

Timezone: Asia/Kolkata (GMT+05:30)

Hello. Thank you for contacting the Toolset support.

Can you please share problem URL where I can see the issue as well as admin access details.

Do you mean before update it used to work and now it stop working?

*** Please make a FULL BACKUP of your database and website.***
I would also eventually need to request temporary access (WP-Admin and FTP) to your site. Preferably to a test site where the problem has been replicated if possible in order to be of better help and check if some configurations might need to be changed.

I have set the next reply to private which means only you and I have access to it.

#2064159

Minesh
Supporter

Languages: English (English )

Timezone: Asia/Kolkata (GMT+05:30)

To check if post has been assigned specific term, you should use the CONTAINS() as given under:

[wpv-conditional if="(CONTAINS(#(collection-publication),'Sentinelle')  ) " debug="true" ]
your code goes here
[/wpv-conditional]

More info:
=> https://toolset.com/documentation/legacy-features/views-plugin/displaying-taxonomies-conditionally/#specific

Can you please convert your conditional statements with CONTAINS() rather using [wpv-post-taxonomy] shortcode on the following page where you added your view:
=> hidden link

[wpv-conditional if=" ( ( '[wpv-post-taxonomy type="collection-publication" format="name"]' eq 'Sentinelle' ) ) " ]
your code 
[/wpv-conditional]
#2064185

Minesh,

I had to take control of the article. Hope it is OK.

It seems that it is working again now.
Do I need to keep the 'debug' parameter?

Can I convert all the other conditional statements?

#2064219

Minesh
Supporter

Languages: English (English )

Timezone: Asia/Kolkata (GMT+05:30)

Yes Ok.

you should convert all your conditional statement where you are checking to see if post has been assigned specific terms.

You can remove the debug attribute.

#2064241

My issue is resolved now. Thank you!