How to remove auto p and br tag.
-
Hi,
I am adding Gutenberg support to one of my themes.
It’s adding p and br tags on custom post type loop.
How can I avoid those tags?
Screenshot: https://puu.sh/AYvSq/07781532ee.png
Thanks
The page I need help with: [log in to see the link]
-
I don’t believe it’s possible to prevent these tags from being automatically added in.
It’s a terrible part of the functionality and has forced me to deactivate the plugin, as it constantly breaks layouts
Hi,
Gutenberg will add paragraph tags to wrap around paragraphs of text, you can remove these with code, by using a filter like for example
the_content
, but they’re the correct tag to be using there if you look at proper HTML markup (which we are making Gutenberg adhere to to better the web).Unfortunately your screenshot is just a cropped section of HTML markup, and does not give us any indication of what is actually content created by Gutenberg, and what is your theme.
If you do need further assistance here, please provide us with the actual code used in your theme file, and perhaps a screenshot of the output with and without Gutenberg active.
Hi Marius L. J. (@clorith),
It’s one of our premium themes(https://themeforest.net/item/wp-education-the-ultimate-wordpress-lms-theme-for-educational-sites/19454725). The theme is based on LearnPress(https://www.ads-software.com/plugins/learnpress/) LMS plugin.
No issue for general pages, it only creates the auto p issue on course archive page.
Archive page – https://puu.sh/B6PeY/ed18150cab.png
Default page same element – https://puu.sh/B6Pgn/67c87a87ec.pngIf you want, I can send the theme file, please give me your email.
Thanks
I feel like that’s a known thing they are looking into (the plugin name rings a bell as someone that’s been communicating with the Gutenberg team about it and are actively working on it), I could be wrong, but it sounds very familiar (either them or another LMS group).
I appreciate the offer to send things over, but that would be against our forum guidelines as we do not allow off-site contact like that. if you could provide snippets of the code where it’s misbehaving though (without giving the whole theme here) that would be super!
Hi Marius L. J. (@clorith),
This plugin has a template override system like WooCommerce.
Here the course archive loop of the plugin –
<li id="post-<?php the_ID(); ?>" <?php post_class(); ?>> <?php // @deprecated do_action( 'learn_press_before_courses_loop_item' ); // @since 3.0.0 do_action( 'learn-press/before-courses-loop-item' ); ?> <a href="<?php the_permalink(); ?>" class="course-permalink"> <?php // @deprecated do_action( 'learn_press_courses_loop_item_title' ); // @since 3.0.0 do_action( 'learn-press/courses-loop-item-title' ); ?> </a> <?php // @since 3.0.0 do_action( 'learn-press/after-courses-loop-item' ); // @deprecated do_action( 'learn_press_after_courses_loop_item' ); ?> </li>
and here our theme override codes –
add_action( 'learn-press/after-courses-loop-item', 'educationpress_learn_press_courses_loop_item_short_description', 10 ); add_action( 'learn-press/before-courses-loop-item', 'educationpress_learn_press_before_course_item_figure', 5 ); add_action( 'learn-press/before-courses-loop-item', 'educationpress_learn_press_before_course_item_thumbnail', 10 ); add_action( 'learn-press/before-courses-loop-item', 'learn_press_courses_loop_item_thumbnail', 15 ); add_action( 'learn-press/before-courses-loop-item', 'educationpress_learn_press_wishlist', 20 ); add_action( 'learn-press/before-courses-loop-item', 'educationpress_learn_press_after_course_item_thumbnail', 25 ); add_action( 'learn-press/before-courses-loop-item', 'educationpress_learn_press_courses_loop_item_figcaption', 35 ); add_action( 'learn-press/after-courses-loop-item', 'ep_course_author', 13 ); if( cs_get_option( 'show_course_enroll_btn_n_price' ) == true ){ add_action( 'learn-press/after-courses-loop-item', 'ep_course_students_enrolle_button', 14 ); } if( cs_get_option( 'show_course_meta' ) == true ){ add_action( 'learn-press/after-courses-loop-item', 'ep_learn_press_courses_loop_item_before_meta', 15 ); if( cs_get_option( 'show_course_students' ) == true ){ add_action( 'learn-press/after-courses-loop-item', 'learn_press_course_students', 17 ); } if( cs_get_option( 'show_course_review' ) == true ){ add_action( 'learn-press/after-courses-loop-item', 'educationpress_course_ratings', 18 ); } add_action( 'learn-press/after-courses-loop-item', 'educationpress_learn_press_courses_loop_item_after_meta', 32 ); } add_action( 'learn-press/after-courses-loop-item', 'educationpress_learn_press_courses_loop_item_figcaption_end', 45 ); add_action( 'learn-press/after-courses-loop-item', 'educationpress_learn_press_after_course_item_figure', 50 ); remove_action( 'learn-press/courses-loop-item-title', 'learn_press_courses_loop_item_thumbnail', 10 ); remove_action( 'learn-press/after-courses-loop-item', 'learn_press_courses_loop_item_price', 20 ); remove_action( 'learn-press/after-courses-loop-item', 'learn_press_courses_loop_item_instructor', 25 ); remove_action( 'learn-press/after-courses-loop-item', 'learn_press_course_loop_item_buttons', 35 ); remove_action( 'learn-press/before-main-content', 'learn_press_search_form', 15 );
if(!function_exists('ep_learn_press_courses_loop_item_before_meta')){ function ep_learn_press_courses_loop_item_before_meta(){ echo '<div class="ep-course-meta">'; } } /** * course loop item after course meta */ if(!function_exists('educationpress_learn_press_courses_loop_item_after_meta')){ function educationpress_learn_press_courses_loop_item_after_meta(){ echo '</div>'; } }
Thanks
I’m not seeing anything obvious here that would be the cause, granted there’s no references to
the_content
either.For reference, here’s the default markup created by Gutenberg for a test post I have on a vanilla site:
<p>This is an example page. It’s different from a blog post because it will stay in one place and will show up in your site navigation (in most themes). Most people start with an About page that introduces them to potential site visitors. It might say something like this:</p> <blockquote class="wp-block-quote"><p>The XYZ Doohickey Company was founded in 1971, and has been providing quality doohickeys to the public ever since. Located in Gotham City, XYZ employs over 2,000 people and does all kinds of awesome things for the Gotham community.</p></blockquote> <p>[myshortcode]</p> <p>…or something like this:</p> <figure class="wp-block-image"><img src="https://feature.test/wp-content/uploads/2018/06/20171205_111524.jpg" alt="" class="wp-image-17" srcset="https://feature.test/wp-content/uploads/2018/06/20171205_111524.jpg 4032w, https://feature.test/wp-content/uploads/2018/06/20171205_111524-300x225.jpg 300w, https://feature.test/wp-content/uploads/2018/06/20171205_111524-768x576.jpg 768w, https://feature.test/wp-content/uploads/2018/06/20171205_111524-1024x768.jpg 1024w" sizes="(max-width: 767px) 89vw, (max-width: 1000px) 54vw, (max-width: 1071px) 543px, 580px"></figure> <blockquote class="wp-block-quote"> <p>Hi there! I’m a bike messenger by day, aspiring actor by night, and this is my website. I live in Los Angeles, have a great dog named Jack, and I like pi?a coladas. (And gettin’ caught in the rain.)</p> </blockquote> <p>As a new WordPress user, you should go to <a href="https://feature.test/wp-admin/">your dashboard</a> to delete this page and create new pages for your content. Have fun!</p>
It ends up looking like this:
There’s no stray linebreaks or unexpected paragraphs (the places that have paragraphs are actual paragraph blocks, and the non-existent shortcode which is treated as plain text just like in the classic editor)
- The topic ‘How to remove auto p and br tag.’ is closed to new replies.