Hi there,
A have a custom field named "Artwork Dimensions" that is a multiline input field.
In the Content Template that belongs to the View where the Artwork Dimensions field is displayed, I'm using a conditional to test whether it's empty, and if it isn't empty, to display the field:
[wpv-conditional if="( '[types field='artwork-dimensions' output='raw'][/types]' ne '' )"]
<p class="artist_artwork_detail_dimensions">[types field='artwork-dimensions'][/types]</p>
[/wpv-conditional]
This conditional doesn't seem to be working. Am I doing something wrong?
Thanks!
Saul
Dear Saul,
I suggest you try to modify those codes as below:
[wpv-conditional if="( '[types field='artwork-dimensions' output='raw' suppress_filters="true"][/types]' ne '' )" debug="true"]
<div class="artist_artwork_detail_dimensions">[types field='artwork-dimensions'][/types]</div>
[/wpv-conditional]
And test again.
More help:
https://toolset.com/documentation/customizing-sites-using-php/functions/#textarea
suppress_filters:
'true' | 'false' (default)
If suppress_filters=’true’, all third party (non WordPress) filters hooked into the_content filter will be removed,
Luo,
Thanks for your response. I replaced my code with your code, and 1) the comparison still failed and 2) there was no debugging output whatsoever.
I ended up solving the problem by changing the syntax. Here's the revised and working snippet:
[wpv-conditional if="( $(wpcf-artwork-dimensions) ne '' )"]
<div class="artist_artwork_detail_dimensions">[types field='artwork-dimensions'][/types]</div>
[/wpv-conditional]
My question is, why does this syntax work and the shortcode syntax not work?
Thank you!
Saul
There should be some compatibility issue in your website, some plugins/theme will apply their custom filters into the_content filter, it will change the textarea field's output, which does not existed in my localhost with a fresh wordpress installation.
I suggest you check the compatibility problem:
please deactivate all other plugins, and switch to wordpress default theme 2019, deactivate all custom PHP/JS code snippets, and test again
Luo,
Thanks for your response. I won't have time to follow the steps you listed to track down the root of this issue right now, but I do have a follow-up question: can you explain the difference between the two syntactical options for referencing custom fields inside conditionals?
[types field='artwork-dimensions'][/types] vs. $(wpcf-artwork-dimensions)
Thank you!
Saul
Types shortcode [types field='artwork-dimensions'][/types] will output the textarea field value applied the_content filter hook:
https://developer.wordpress.org/reference/hooks/the_content/
So other plugins/theme can take effect on the output result.
But $(wpcf-artwork-dimensions) does not apply the_content filter hook.
You can add debug="true" attribute in wpv-conditional shortocde to compare the difference. see our document:
https://toolset.com/documentation/user-guides/conditional-html-output-in-views/
debug (optional): it can be set to true or false and controls whether to display debug information for administrators.
That makes sense. Thanks for the link to the documentation, Luo!
Saul