***Tell us what you are trying to do?***
I am building a list view where i query "registration" post type and I display different fields.
Registration is a child of either workshop, formation or travel. Certain fields need to be picked up in the parent.
I was able to retrieve the featured image of the parents like this
[code]
<!-- /*FORMATIONS*/ -->
[wpv-conditional if="( '[wpv-post-id id="$formation"]' )"]
[wpv-post-featured-image id="$formation"]
[/wpv-conditional]
[/code]
Then when trying to link the post_url the same condition won't work for all my registration.
I try many different conditional statement that I found here on the forum but I can't quite get it
such as
[code]
[wpv-conditional if="( $(wpcf-description).id(workshop) ne '' )"]
[types field='titre-court-de-l-evenement' output='raw'][/types]
[/wpv-conditional]
[/code]
or
[code]
[wpv-conditional if="( $(_wpcf_belongs_workshop) ne '' ) )"]
Display workshop title and link
[/wpv-conditional]
[/code]
Hi, assuming you're not using the new M2M beta plugins, this syntax should work:
[wpv-conditional if="('[wpv-post-field name='wpcf-description' id='$workshop']' ne '' )"]
**ADD SOME PLAIN TEXT HERE SO SOMETHING IS VISIBLE EVEN IF THE TITRE CUSTOM FIELD IS EMPTY**
<a style="color:#000:" href="[wpv-post-url id="$workshop"]">
[types field='titre-court-de-l-evenement' output='raw'][/types]
</a>
[/wpv-conditional]
If this is not working as expected, please copy + paste the wpv-post-field shortcode outside the conditional, and add the debug parameter to the conditional shortcode:
That is really strange. In pink is the output of the workshop title without any condition and all worked fine!
There is just two of my workshops that won't display. But after observation, I can say that those 2 activities contain apostrophe in the name like --> l'automne and when i test with other title with apostrophes it's not working.
Is there a runaround without changing my workshop names (apostrophes are important in French) ?
I don't think there should be any problems with apostrophe characters in post titles unless you try to use the post title in a conditional. I would recommend using post slug in conditionals instead. Can I log in to your wp-admin area to see what's going on here? Private reply fields are enabled here.
Also, in frontend there is 3 event without the link in the title ( 2 cloud in shape of horse and the one below) and I use the field custom field "titre" that contains the apostrophe.
Item #1 is this Inscription post: hidden link
The parent Formation post: hidden link
Here is the conditional:
The problem here is that there is no custom field 'wpcf-titre' on the Formation post type. Are you comparing the field 'wpcf-titre-court-de-l-evenement', or should it be [wpv-post-title id='$formation']?
...and now the View seems to be working as expected. Can you confirm? If this works, you should be able to change any of the apostrophe characters to their HTML equivalent.
Thank you.
The strangest thing is that I have another custom field that I try to build the same way and it's not working neither.
It's a pdf that i need to display depending on the cpt it belongs to.
If cpt-x display button with link to the pdf in parent.
When i built the condition, it shows a button for every cpt or a link to the current page.
Sorry I took long to come back
And thank you for your precious help.
I really try to understand this conditional to parent and its behaviour!
Christian is on vacation this week, so I'll will carry on here if that's okay.
Looking at your last update, the third format would only be relevant if you are using the current beta versions.
Assuming you are using the stable plugin versions then the $ format to specify the parent should be correct.
Now, I understand that the context for where you are using these conditional shortcodes is when displaying a registration custom post, and you want to conditionally display a button that links to a "lien-vers-le-pdf" custom field that belongs to a "atelier-et-rite" parent post. (The button should only display if such a custom field exists.)
Now, I understand that the context for where you are using these conditional shortcodes is when displaying a registration custom post, and you want to conditionally display a button that links to a "lien-vers-le-pdf" custom field that belongs to a "atelier-et-rite" parent post. (The button should only display if such a custom field exists.)
Yes that is the case.
I have 3 different (formation, voyage, atelier-et-rite) CPT that share one child (inscription) and I want to get the link from the custom field 'lien-vers-le-pdf' that belong to the right parent.
If parent 'atelier-et-rite' has non empty 'lien-vers-le-pdf' display url of 'lien-vers-le-pdf' as a button link.
if parent is not 'atelier-et-rite' or has empty 'lien-vers-le-pdf' display nothing.
I will take care of this thread, I suggest you try to debug the codes manually, for example:
You can output the parent field value directly:
[wpv-post-field name='lien-vers-le-pdf' id='$atelier-et-rite']
Check if it does output field value correctly.
If the custom field "lien-vers-le-pdf" is created with Types plugin, you will need pre-pend "wpcf-" before the field slug in Views shortcode [wpv-post-field], for example:
[wpv-post-field name='wpcf-lien-vers-le-pdf' id='$atelier-et-rite']