Home › Toolset Professional Support › [Resolved] 's appear everywhere after adding conditional code
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.
Our next available supporter will start replying to tickets in about 0.88 hours from now. Thank you for your understanding.
Sun | Mon | Tue | Wed | Thu | Fri | Sat |
---|---|---|---|---|---|---|
- | 10:00 – 13:00 | 10:00 – 13:00 | 10:00 – 13:00 | 10:00 – 13:00 | 10:00 – 13:00 | - |
- | 14:00 – 18:00 | 14:00 – 18:00 | 14:00 – 18:00 | 14:00 – 18:00 | 14:00 – 18:00 | - |
Supporter timezone: Asia/Kolkata (GMT+05:30)
This topic contains 17 replies, has 3 voices.
Last updated by szymonF 2 years, 11 months ago.
Assisted by: Minesh.
<p>'s appear * - title removed the code.
This is a follow up from this thread where Waqar helped me sort out a conditional to display content depending on whether post body contains a string: https://toolset.com/forums/topic/get-the-conditional-to-check-if-the-post-body-contains-a-string/
I am trying to apply the same solution in a different content template and get unexpected effects. The original solution was used in a content template that displays posts in the main loop. I am now trying to apply it in a template that displays single posts - the two are near-identical, the only difference is that the loop one is folded with an accordion, while the single post one is not.
The original solution works fine in the loop posts, but copied over to the single post template, it does a weird thing - it adds <p> tags everywhere, which messes up the looks. See images - the first is in the loop, the second is single. Is there a way to avoid that?
Here are examples:
In loop: hidden link
Single: hidden link
Here is the new conditional I am using:
<div class="article-abstract"> [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"] </div>
If I remove the conditional in the Single post template and have just
<div class="article-abstract"> [wpv-post-body view_template="None" suppress_filters="true" output="raw"] </div>
then it works just fine.
Note: both content templates have Manual paragraphs selected as Output mode.
Note: I also tried to apply the loop content template to single post display and got the same effect - the same content template works fine in the loop, but not with Usage > single pages > posts.
Hello. Thank you for contacting the Toolset support.
Can you please share admin access details so I can check whats going wrong on single post page and why P tags are printed.
*** Please make a FULL BACKUP of your database and website.***
I would also eventually need to request temporary access (WP-Admin and FTP) to your site. Preferably to a test site where the problem has been replicated if possible in order to be of better help and check if some configurations might need to be changed.
I have set the next reply to private which means only you and I have access to it.
Can you please check now: hidden link
I've removed all the spaced added to div and adjusted the code as given under:
<div class="article-abstract">[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"] </div>
Can you please confirm it works as expected?
Thank you for looking into this!
I'm afraid I don't see any change - it's the same as it was on my end
Can you please tell me what section you are targeting as when I inspect the element and see the "Publisher’s Note: " I do not see the P tag. Its inside Div now.
I also see with some content you added the P tag:
=> hidden link
Please check the following screenshot:
=> hidden link
In my first post, I attached a picture that shows what the problem is. As you can see on it, the <p> tags that cause the most mayhem are the ones in between all the social and reference icons. But they are everywhere.
I only want the tags that I added and the ones that just display with the post content of course. I don't want any other <p> tags appearing in between images and other elements.
For some place when I remove the spaces it works as expected but especially it has the issue with the "article-export" div and within that div it adds p tag.
I checked and I see the content template renders the correct HTML but it when content template output interacts with your theme it generates the p tags.
Can you please check if you can switch to default theme 2021 and see if you still see the issue?
Yes, when I switch to 2021 it does seem to work fine. The whole looks pretty messed up, but the <p>'s are not there.
But naturally I do want to keep using my theme. What can be done?
You will have to check with your theme author to know what is inside the theme (filter/action) that causes this issue as I shared Toolset delivers the correct content but theme adds those extra P tags from somewhere during the page gets rendered. I suggest you should contact your theme author and check with them and ask for possible solution or workaround.
Quick reply just to keep the ticket open while I'm in conversation with the theme developer.
Ok fine.
Alas, didn't get anywhere with the theme developer. They say:
-----
I've had a look and it's going to be quite complicated for me to work this out as I've never used the Toolset plugin before, and I'm not 100% sure how it's working here.
The way the theme works it basic and very lightweight, the theme offers different header and footer layouts and the initial site layout and design, but the theme doesn't add or edit functionality to the content areas... This is why I recommend Elementor or the default editor for users to build their content with.
Have you tried de-activating plugins to see if it's maybe another plugin conflicting with Toolset here?
If you haven't, try de-activating all plugins except Toolset and then check if it works, then activate them one by one to see if it comes back.
Otherwise, I think the Toolset developers should hopefully be able to narrow down why this is happening exactly, and if it's something in the theme then you/they can let me know and I'll fix it, but I honestly have no ideas why or how <p> tags would be getting injected here.
-----
I checked and deactivating plugins didn't help. Any thoughts on what the point of conflict could be?
Minesh won't be available for a couple of days. If you don't mind, I'll continue with you on this ticket. As Minesh explained and as you were able to confirm with the 2021 theme, the issue is produced by the theme.
I wanted to check the theme's file, maybe I'll spot something, but the theme's editor is disabled, and I cannot install a plugin to browse the theme's files.
On the other hand, for the empty tags, I'll suggest this custom Javascript code to remove them, I added it to the content template's Javascript section and it does remove the empty <p> tags. It does not touch those who contain a link(article-export section).
Without a proper fix on the theme, I am afraid Javascript is the only workaround. Let me know if you want to handle other <p> tags, share a wider screenshot when possible.
Hi Jamal,
Thank you for your help! I'm not sure if the solution works though - I still see the content messed up, but now it looks like the added tags are not <p>'s but <br>'s! Also, the <p>'s that are in between the export icons are not empty - for some reason they seem to copy <a> tags from around them, just without any display content. What is going on?
See e.g. here: hidden link
Compare with: hidden link (test site without your extra Javascript)
As you can see with the content template:
=> hidden link
There are number of <br /> tags added manually its not due to Toolset. You should try to search within your content template and you will notice where and how many <br > tags added. Please check the following screenshot:
=> hidden link