Tell us what you are trying to do? Use $current_page CPT value in wpv-conditional statement in a view
I have a view displaying a CPT "X" and that view shortcode has been added to the single template of CPT "Y", I need to use a field value from CPT "Y" (named headlineactivereplies) in a wpv-conditional statement in the view. I'm trying to do something like this (I know it's wrong but you'll get the idea):
[wpv-conditional if="( $(wpcf-headlineactivereplies) id='$current_page' eq '1' )"]YES[/wpv-conditional]
[wpv-conditional if="( $(wpcf-headlineactivereplies) id='$current_page' eq '0' )"]NO[/wpv-conditional]
Can you help me format that correctly?
Shane
Supporter
Languages:
English (English )
Timezone:
America/Jamaica (GMT-05:00)
Hi Bobby,
Thank you for getting in touch.
The correct way should be.
[wpv-conditional if="( '[type field='headlineactivereplies' item='$current_page']' eq '1' )"]YES[/wpv-conditional]
Try it like this and let me know.
Thanks,
Shane
Thanks Shane! I've updated my shortcode to this:
[wpv-conditional if="( '[type field='headlineactivereplies' item='$current_page']' eq '1' )"]YES[/wpv-conditional]
[wpv-conditional if="( '[type field='headlineactivereplies' item='$current_page']' eq '0' )"]NO[/wpv-conditional]
But it doesn't output anything 🙁 and the main page does have a 0 or 1 value for "headlineactivereplies".
Could it be a ' VS " problem in the shortcode?
Shane
Supporter
Languages:
English (English )
Timezone:
America/Jamaica (GMT-05:00)
Hi Bobby,
If you add this shortcode to the page only what does it return ?
[type field='headlineactivereplies' item='$current_page']
Please let me know.
Thanks,
Shane
I found the problem! The code you sent me was missing an "s" in types:
[wpv-conditional if="( '[type field='headlineactivereplies' item='$current_page']' eq '1' )"]YES[/wpv-conditional]
[wpv-conditional if="( '[types field='headlineactivereplies' item='$current_page']' eq '1' )"]YES[/wpv-conditional]
That fixed it! Thank you so much for the help!