Skip Navigation

[Resolved] Use $current_page CPT value in wpv-conditional statement in a view

This support ticket is created 5 years 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
- 9:00 – 12:00 9:00 – 12:00 9:00 – 12:00 9:00 – 12:00 9:00 – 12:00 -
- 13:00 – 18:00 13:00 – 18:00 13:00 – 18:00 14:00 – 18:00 13:00 – 18:00 -

Supporter timezone: America/Jamaica (GMT-05:00)

Tagged: 

This topic contains 4 replies, has 2 voices.

Last updated by Bobby339 5 years ago.

Assisted by: Shane.

Author
Posts
#1388211

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?

#1388213

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

#1388235

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?

#1388241

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

#1388245

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!