Archived topic
Disable auto paragraph
13 replies · Started by Kelvin on June 6, 2019
Dear Sir/Madam,
I am not sure whether it is the issue from GeneratePress theme, I didn't have similar issue from others
I want to add only shortcode into my page body
[mobileonly][wpv-view name="home-slider-gallery-mobile"][/mobileonly] [desktoponly][wpv-view name="home-slider-gallery"][/desktoponly]
Every time after I save the post, the code will be saved as
<p>[mobileonly]</p>
[wpv-view name="home-slider-gallery-mobile"]
<p>[/mobileonly] [desktoponly]</p>
[wpv-view name="home-slider-gallery"]
<p>[/desktoponly]</p>
The auto-paragraph tag is added automatically.
Hi there,
AutoP is something WP does, and it can be very annoying. This article provides some code and plugin methods for stopping that:
https://wpcatalogue.com/how-to-disable-automatic-paragraph-tags-in-wordpress/
Dear David,
Thanks for your information, I added the
remove_filter (‘the_content’, ‘wpautop’);
remove_filter (‘the_excerpt’, ‘wpautop’);
but can only work for the classic editor but not Block editor.
Best regards,
Kelvin.
In the block editor you can use the shortcode block or the Custom HTML block, they should not be affected by the AutoP
Dear David,
Thanks for your reply. How can I use the Custom HTML block, I can only find the Section but can't Custom HTML block. (https://prnt.sc/nyv0t9)
Sorry - the Block is only available in the Block editor which doesn't work with GP Sections. As you're using sections why not just use the Classic Editor on those pages?
Dear David,
I don't know how to manage the section in classic mode, I need to use the sections as full width and contained alternatively. I know HTML code.
The Classic Editor plugin provides you an option in its settings to enable opening in either classic or block editor:
Dear David,
Yes, I edit the page with the classic editor (https://prnt.sc/nyve8s) but I still get the same screen (https://prnt.sc/nyv0t9). If I disable the "Use Sections" (https://prnt.sc/nyvgso), I can't set the attribute of each section.
Adding paragraphs is something the classic editor does, and Sections use the classic editor.
Do the <p> elements prevent the shortcodes from working?
Dear Tom,
Sorry, I don't understand your message. I only know every time I save the post purely with shortcodes and the <p> elements automatically be added. If I use the classic editor then I can find the attribute set for each section. If I use block editor, I can't find the Custom HTML block but only the section.
Best regards,
Kelvin
I only know every time I save the post purely with shortcodes and the
elements automatically be added.
Unfortunately, this is just something WordPress does in the Classic Editor as of WordPress 5.0. Before 5.0, it didn't show the <p> elements even though they were there.
Do those <p> elements prevent the shortcodes from functioning?
Dear Tom,
Yes, the <p> elements affect the shortcode from functioning. I have a slider made by Toolset, I add the shortcode
[mobileonly][wpv-view name="home-slider-gallery-mobile"][/mobileonly] [desktoponly][wpv-view name="home-slider-gallery"][/desktoponly]
The <p> elemenet automatically be added
<p>[mobileonly]</p>
[wpv-view name="home-slider-gallery-mobile"]
<p>[/mobileonly] [desktoponly]</p>
[wpv-view name="home-slider-gallery"]
<p>[/desktoponly]</p>
You can find the paragraph space is added (https://prnt.sc/nzki1z)
What if you add it all to one line? Here's what I get after saving when I do that: https://www.screencast.com/t/7eacAkqwtO