I am trying to display content conditionally if the post type is products of WooCommerce.
This solution work for other post type just fine. but when i insert "product" as a slug it seems not to work
WORKS FINE:
[wpv-conditional if="( '[wpv-post-type]' eq 'post' )"]
THIS is PRODUCT POST TYPE
[/wpv-conditional]
DOESN'T WORK:
[wpv-conditional if="( '[wpv-post-type]' eq 'product' )"]
THIS is PRODUCT POST TYPE
[/wpv-conditional]
Nigel
Supporter
Languages:
English (English )
Spanish (Español )
Timezone:
Europe/London (GMT+00:00)
Where are you using this?
I created a content template for single product posts and added the following
<p>Post type: [wpv-post-type]</p>
[wpv-conditional if="( '[wpv-post-type]' eq 'product' )"]
This is a product
[/wpv-conditional]
It outputs
Post type: product
This is a product
I suspect the context where you are using it is wrong.
Thanks Nigel for your Reply.
I have tested your code and i found a problem with the slug name of the post type which causing this Issue.
following code wont work:
<p>Post type: [wpv-post-type] </p>
[wpv-conditional if="( '[wpv-post-type]' eq 'product' )"]
This is a product
[/wpv-conditional]
following code works:
<p>Post type: [wpv-post-type] </p>
[wpv-conditional if="( '[wpv-post-type]' eq '/product' )"]
This is a product
[/wpv-conditional]
I dont know why the slug name is adding an extra "/" , please see screenshot.
maybe this also connected to this unsolved ticket? https://toolset.com/forums/topic/text-issue-when-using-special-character-like/
BTW i am using the code in Toolset Cred form and tried to use it in Layout Template but the issue is in both cases there.
Nigel
Supporter
Languages:
English (English )
Spanish (Español )
Timezone:
Europe/London (GMT+00:00)
It's not the same issue (backslash to escape characters on the other thread, a forward slash in this thread).
Can you confirm if this happens when you disable all plugins except Toolset and WooCommerce, and switch theme to twentyseventeen?
What is the language of your site?
I will follow your suggestion and let you know if this helps!
Its Hebrew
Thanks
My issue is resolved now. Thank you!
I have followed all your suggestions but seems not to work.
I have looked at the permalinks and changed the "Product permalinks" from custom to default and saved.
this has automatically deleted an extra backlash from the permalink from "/product/" to "product/"