Archived topic
Use Sections -> auto adding paragraphs
17 replies · Started by Radu on January 31, 2016
Hi Tom,
When using the "Use Sections" option, the editor automatically adds paragraph tags (<p> and</p>) even if the visual editor is disabled.
Is this the normal behaviour?
Thanks,
Interesting - you may have found another bug. I'll look into this ASAP :)
This has been fixed in the next version (GP Premium 1.2.80) :)
Hey Tom,
I am still getting <p> tags added to my links in sections. I am using version 1.3.31. I am also using the Toggle wpautop plugin to remove Wordpress' automated <p> tags. Is there a quick fix to this problem?
Thanks,
Adam
You can add this function to your site:
if ( ! function_exists( 'generate_sections_filter_admin_init' ) ) :
add_action( 'admin_init','generate_sections_filter_admin_init' );
function generate_sections_filter_admin_init()
{
if ( user_can_richedit() ) {
add_filter( 'generate_section_content', 'convert_smilies' );
add_filter( 'generate_section_content', 'convert_chars' );
add_filter( 'generate_section_content', 'wpautop' );
add_filter( 'generate_section_content', 'shortcode_unautop' );
add_filter( 'generate_section_content', 'prepend_attachment' );
}
}
endif;
Then remove the wpautop line.
Adding PHP: https://generatepress.com/knowledgebase/adding-php-functions/
Hello Tom.
I'm still getting this issue and I try as you've said but I'm getting a fatal error because the function is already declared in plugin file.
Do you know how to solve this?
Thanks.
What's the exact code you're adding? The function_exists() call will prevent any fatal error from happening.
Hello Tom.
I'm adding exactly the code above (yours), but I was writing the function outside the if statement. Now I'm not getting the fatal error but still remains one of the two paragraph tags, just the one between an img and a heading tag.
Regards.
So you're trying to remove the automatic placement of paragraphs completely inside Sections?
Hi Tom.
Yes, inside a div tag I've got an img tag and then a h3 tag, I don't want the p tag the editor insert between both.
Regards.
BTW, I know you're very busy but, please, can you take a look at this? https://wpshowposts.com/support/topic/filtering-posts/
I really need you to give me a hand.
Thanks in advance!
Try this:
add_action( 'wp', 'tu_remove_sections_wpautop', 15 );
function tu_remove_sections_wpautop() {
if ( is_admin() || ! is_singular() ) {
return;
}
$sections = get_post_meta( get_the_ID(), '_generate_sections', TRUE);
if ( $sections ) {
remove_filter( 'the_content', 'wpautop' );
}
}
Hello.
No, it doesn't work neither.
I just made a couple adjustments to the code - can you try it now?
Hi Tom.
No, it doesn't works neither.
You can see it at this to pictures: https://prnt.sc/hh79vh and https://prnt.sc/hh7akh