[Resolved] Conditional check for string in body of child post
This support ticket is created 2 years, 3 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.
The idea was to scan post text for words such as 'Abstract:', 'Publisher's note:', etc. - if they don't appear, the conditional display will add them, but if they do appear, the conditional display won't add them.
I want to use the same solution in different views. In one of them, the posts displayed are just posts, and it all works fine. Thank you Waqar 🙂 Here is an example: hidden link entry: Midgley, Mary. Individualism and the Concept of Gaia. This is the code I am using:
[wpv-conditional if="( '[body_text_contains needle='Abstract:']' eq '0' ) AND ( '[body_text_contains needle='Note:']' eq '0' ) AND ( '[body_text_contains needle='note:']' eq '0' ) AND ( '[body_text_contains needle='Matter:']' eq '0' ) AND ( '[body_text_contains needle='matter:']' eq '0' ) AND ( '[body_text_contains needle='Syllabi']' eq '0' ) AND ( '[body_text_contains needle='Introduction:']' eq '0' ) AND ( '[body_text_contains needle='Content:']' eq '0' ) AND ( '[body_text_contains needle='Summary:']' eq '0' ) AND ( '[body_text_contains needle='Conclusion:']' eq '0' )"]
[wpv-conditional if="( $(wpcf-medium) eq '1' )"]<strong>Publisher's Note: </strong>[/wpv-conditional]
[wpv-conditional if="( $(wpcf-medium) ne '1' )"]<strong>Abstract: </strong>[/wpv-conditional]
[/wpv-conditional]
[wpv-post-body view_template="None" suppress_filters="true" output="raw"]
In the other view, the posts are part of a relationship, so what is displayed is an intermediary post that draws data from the child post. Here is an example: hidden link entry: Midgley, Mary. Individualism and the Concept of Gaia. Unfortunately, here the code is not working and I get the word 'Abstract:' twice - once because it's part of the post, the second time added by the content template. This is the code I am using: