Skip Navigation

[Resolved] Inserted tags in form content

This thread is resolved. Here is a description of the problem and solution.

Problem:
I am trying to: get my form to display normally with layouts template as page template. The form shortcode is in the post body. A form showing with extra p and br tags

Solution:
1. To remove extra paragraph tags, please add the following code in your theme’s functions.php file:

remove_filter( 'the_content', 'wpautop' );
 add_filter( 'the_content', 'wpautop' , 12);
  
add_filter('the_content', 'remove_empty_p', 20, 1);
function remove_empty_p($content){
    $content = force_balance_tags($content);
    return preg_replace('#<p>\s*+(<br\s*/*>)?\s*</p>#i', '', $content);
}

2. You can also try [wpv-noautop] shortcode and place all your content inside this:
https://toolset.com/documentation/user-guides/views-shortcodes/#wpv-noautop

Alternate solution used by the client: Formidable plugin has an option to minimize HTML. This stops the extra tags from being generated.

Relevant Documentation:
http://sww.nz/solution-to-wordpress-adding-br-and-p-tags-around-shortcodes/
https://toolset.com/documentation/user-guides/views-shortcodes/#wpv-noautop

This support ticket is created 7 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.

Sun Mon Tue Wed Thu Fri Sat
- 12:00 – 17:00 12:00 – 17:00 12:00 – 17:00 12:00 – 17:00 12:00 – 17:00 -
- 18:00 – 21:00 18:00 – 21:00 18:00 – 21:00 18:00 – 21:00 18:00 – 21:00 -

Supporter timezone: Asia/Karachi (GMT+05:00)

This topic contains 2 replies, has 2 voices.

Last updated by glenn 7 years, 3 months ago.

Assisted by: Noman.

Author
Posts
#536728
screen.jpg

I am trying to: get my form to display normally with layouts template as page template. The form shortcode is in the post body.

I visited this URL: Still on local. Included a screenshot

I expected to see: A form without extra p and br tags

Instead, I got: A form with extra p and br tags

#536806

Noman
Supporter

Languages: English (English )

Timezone: Asia/Karachi (GMT+05:00)

Hi Glenn,

Thank you for contacting Toolset Support. This could happen in some sites or themes.

1. To remove extra paragraph tags, please add the following code in your theme’s functions.php file:

remove_filter( 'the_content', 'wpautop' );
 add_filter( 'the_content', 'wpautop' , 12);
 
add_filter('the_content', 'remove_empty_p', 20, 1);
function remove_empty_p($content){
    $content = force_balance_tags($content);
    return preg_replace('#<p>\s*+(<br\s*/*>)?\s*</p>#i', '', $content);
}

2. You can also try [wpv-noautop] shortcode and place all your content inside this:
https://toolset.com/documentation/user-guides/views-shortcodes/#wpv-noautop

Related Docs:
hidden link
https://toolset.com/documentation/user-guides/views-shortcodes/#wpv-noautop

Thank you

#537148

Hi Norman,

thank you for your reply. I already had that code added to my functions.php. But it didn't do anything.

I found another solution in the end. Formidable has an option to minimize HTML. This stops the extra tags from being generated.

[noautop] Seems very specific in how you must implement it. I crated a view. When i placed the tags inside the loop, nothing happens. Only when i placed it outside the loop did it work. I am just wondering if it wouldn't be better for views/layout combination to always strip any extra tags. Since this will probably mostly be used by theme developers the don;t want the extra tags.

Anyhow thank you for your quick reply and support.

Kind regards,

Glenn Windhouwer

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