Skip Navigation

[Resolved] wpv-post-body view_template="None" stripping out anything but plain text

This support ticket is created 5 years, 6 months 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.

No supporters are available to work today on Toolset forum. Feel free to create tickets and we will handle it as soon as we are online. Thank you for your understanding.

Sun Mon Tue Wed Thu Fri Sat
8:00 – 12:00 8:00 – 12:00 8:00 – 12:00 8:00 – 12:00 8:00 – 12:00 - -
13:00 – 17:00 13:00 – 17:00 13:00 – 17:00 13:00 – 17:00 13:00 – 17:00 - -

Supporter timezone: America/New_York (GMT-04:00)

This topic contains 3 replies, has 2 voices.

Last updated by Christian Cox 5 years, 6 months ago.

Assisted by: Christian Cox.

Author
Posts
#1130044

I am trying to:
Conditionally display the main body section of a post. If it is filled out, show the post content, if it is not, show a video. I have the following check within my view loop editor:

                  [wpv-conditional if="( '[wpv-post-body view_template='None']' eq '' )"]
                  <iframe class="uk-responsive-width" width="531" height="395" src="-masked-" frameborder="0" allow="autoplay; encrypted-media" allowfullscreen></iframe>
                  [/wpv-conditional]
                  [wpv-conditional if="( '[wpv-post-body view_template='None']' ne '' )"]
                  <div>[wpv-post-body view_template="None"]</div>
                  [/wpv-conditional]

It works, but if an image or video is inserted into the post content area, nothing shows up at all.

Link to a page where the issue can be seen: hidden link

I expected to see:
My content for this post is

This is a sample listing. If you are a certified listing, you will see a video display here

<img class="alignnone size-full wp-image-269" src="<em><u>hidden link</u></em>" alt="" width="300" height="250" />

It should be displayed to the right of the listing information.

Instead, I got: The entire area does not load because I put an image or video in the content. If I remove the image or video and leave simply the text, it appears fine. If I leave the content area blank, my default iframe displays fine.

Any ideas?

#1130073

Hi, I presented the solution to a similar problem in another ticket. Check the answer here:
https://toolset.com/forums/topic/conditional-output-if-the-post-content-is-filled/

This solution may need to be tweaked for your site, let me know if you get stuck.

#1130725

Hi Christian,

I gave this a try the way you did it which was very similar to how I had it setup and couldn't actually get it to work at all that way. I reverted back to the way I had it, but wanted to be sure you understood my problem isn't in getting the content to display dynamically, its more that Toolset is scanning the content and stripping it somehow if it includes anything but plain text.

Posting plain text into the WordPress content area = shows OK
Posting nothing into the WordPress content area = does not show (as desired)
Posting text and an image, or a media embed into the content area = does not show up (not desired)

#1131464
post.png
content-template.png
front-end.png

There must be something else going on, because the solution I provided seems to work with plain text or HTML content in the post body on my local test site. I'm attaching some screenshots here showing a post with an img tag in its content, the assigned Content Template with a conditional, and the front-end post showing the conditional content. If it didn't work for you, please try the following troubleshooting steps:
- Go to Toolset > Settings > Frontend Content and check the "Functions inside conditional evaluations" panel. Make sure you added the correct function name here: wpv_conditional_post_has_content.
- Make sure your conditionals are testing for the values 1 and 0, not an empty string ''. The function I provided will not return an empty string.
- Simplify the output in each conditional. Remove any shortcodes and just place some basic text to confirm the conditionals are working, then replace the contents inside each conditional.
- Temporarily switch to a default theme like Twenty Seventeen, and deactivate all plugins except Types and Views. Test again. If the problem is resolved, reactivate your theme and other plugins one by one until the problem returns.

Let me know the results of these steps and we can go from there.

This ticket is now closed. If you're a WPML client and need related help, please open a new support ticket.