php - Remove the opening and closing div inside WordPress content -


i want remove div added plugin content of wordpress posts. post has structure:

<div class="post">    <div class="some-class">        <p>content</p>    </div> </div> 

i want remove <div class="some-class"> , closing </div> leave content. be:

<div class="post">        <p>content</p> </div> 

using filter:

add_filter( 'the_content', 'remove_class' , 100 );  function remove_class( $content ) {             $content = preg_replace('#<div[^>]*class="some-class"[^>]*>.*?</div>#is', '', $content);             return $content;         } 

the content deleted, want div , closing div deleted. idea how?

  • this question not duplicate of other question because want remove specific div not divs

you try remove class attribute, <div> left, using code this:

add_filter( 'the_content', 'remove_class' , 100 );  function remove_class( $content ) {             $content = preg_replace('/class=".*?"/', '', $content);             return $content;         } 

Comments

Popular posts from this blog

ubuntu - PHP script to find files of certain extensions in a directory, returns populated array when run in browser, but empty array when run from terminal -

php - How can i create a user dashboard -

javascript - How to detect toggling of the fullscreen-toolbar in jQuery Mobile? -