Tell us what you are trying to do?
Display post relationship name in loops. Before it was working with the following code, but it suddenly stopped working and it's showing the product title instead of the author title (related custom post).
The code I use is:
[wpv-conditional if="( $(wpcf-varios-autores) gt '0' )" evaluate="false"]<h3 class="book-author-shop">[wpv-post-link id="[wpv-post-field name="_wpcf_belongs_autor_id"]"]</h3>[/wpv-conditional]
[wpv-conditional if="( $(wpcf-varios-autores) gt '0' )"]<h3 class="book-author-shop">VV.AA.</h3>[/wpv-conditional]
A conditional, if there are more than 1 posts related to the product, then it prints VV.AA. If not, it prints the name of the author.
Is there any documentation that you are following?
Yes, read some articles but still dont find the way.
Is there a similar example that we can see?
My website.
What is the link to your site?
lenguadetrapo.com
Hello and thank you for contacting the Toolset support.
This code is using the old relationships from Toolset Types 2.x and it will no longer work for the recent versions. I am not sure how the relationship is set but it is more likely to be a one-to-many relationship.
Because you want to display two different values based on the number of related posts, I think, that the most straightforward way will require some custom code to check how many related posts are there. The custom code can use the toolset_get_related_posts from our relationship API. Read more about it here https://toolset.com/documentation/customizing-sites-using-php/post-relationships-api/#toolset_get_related_posts
If you are unsure how to implement this custom code, allow me temporary access to check how the relationship is set, and let me know where this code is used and I'll be happy to help. Your next reply will be private to let you share credentials safely. ** Make a database backup before sharing credentials. **
Hello,
Sorry, the support ticket got closed, i was away these days. I'm ready to gove you full access to the site. Thanks.
Your next reply will be private to let you share credentials safely. Your next reply will be private to let you share credentials safely. ** Make a database backup before sharing credentials. **
Let me know if I can take a copy of your website in case I need to do more debugging on my local setup.
When I first see the code below, I thought that the relationship is a one-to-many or one-to-one relationship
[wpv-post-link id="[wpv-post-field name="_wpcf_belongs_autor_id"]"]
It turns out to be a many-to-many relationship as you can see in this screenshot hidden link
To display a related post in a many-to-many relationship, we use a view of the related posts to the current post of the view, or to the current post in the loop. Then you can use the shortcodes inside the view without using the id attribute or the item attribute.
I built a content template and a view to give an example, but I can't preview a product or an autor using the content template because both custom post types use a Toolset layout, which takes precedence. I noticed that you already have a similar view in an autor layout. Check this screenshot hidden link
The view is hidden link
I hope this answers your question. Otherwise, please let me know where can I find the code you shared in your first message?