Skip to:
Content
Pages
Categories
Search
Top
Bottom

Can I disable wpautop() only for Buddypress? Unwanted paragraph tags everywhere.


  • Hendrik Lersch
    Participant

    @riddler84

    Hello, i’m a beginner when it comes to buddypress, so i hope anybody here can help me. I try to style my own BP theme and have noticed a curiously behavior.

    Is it normal that Buddypress routes all the .php templates through WP’s the_content() function?
    Because I now have the problem, that the wpautop() function putting empty paragraph tags (<p></p>) everywhere in my code.

    Every double line break inside the html code transforms into a paragraph and every normal line break into an unwanted <br> tag. Also every HTML Comment like <!– #item-header-avatar –> will put into a paragraph tag.

    I’ve had this from the beginning, so i dont’t think i have done a mistake. Can I fix this in some way? I could disable wpautop(), but i need it for normal pages and articles. Please help 🙂

    I use WP 4.4 and BP 2.4.3.

Viewing 1 replies (of 1 total)

  • Hendrik Lersch
    Participant

    @riddler84

    Have found the solution by myself. If anyone interested, here’s the code i have added to my bp-custom.php. i think it works as well in the themes functions.php.

    function remove_wpautop_from_buddypress() {
    	if( bp_current_component() ) {
    		remove_filter( 'the_content', 'wpautop', 99 );
    	}
    }
    add_action('bp_init', 'remove_wpautop_from_buddypress');

    bp_current_component() is true, if you be on a buddypress page, so wpautop is only disabled there.
    But i still wonder, why it’s necessary to do something like that. 😉

Viewing 1 replies (of 1 total)
  • The topic ‘Can I disable wpautop() only for Buddypress? Unwanted paragraph tags everywhere.’ is closed to new replies.
Skip to toolbar