Cleaning posts text area

Posted in: Newspaper
Post count: 113

Hi, the migration from blogger has added some rubbish to many posts.
https://ibb.co/TKrZxZj
As yo can see <br> have been added. Do you know any way to replace <br> tag for ‘ ‘ or delete them directly. I found something like that but it´s doesn´t work obviously, but its the idea.

//Limpiar los textarea de br,p, y demás basura

function clean_textarea2($matches) {

 if ( is_array($matches) )

 $text = $matches[1] . $matches[2] . "</textarea>";

 else

 $text = $matches;

 

 $text = str_replace('<br>', ' ', $text);

 $text = str_replace('“', '"', $text);

 $text = str_replace('”', '"', $text);

 $text = str_replace('‘', "'", $text);

 $text = str_replace('’', "'", $text);

 $text = str_replace('′', "'", $text);

 return $text;

}

function clean_textarea($pee, $br = 1) {

 if (strpos($pee, '<textarea') !== false)

 $pee = preg_replace_callback('!(<textarea.*?>)(.*?)</textarea>!is', 'clean_textarea2', $pee );

 return $pee;

}

add_filter('the_content', 'clean_textarea'); 
  • This topic was modified 5 years by loslunes.
Post count: 18283

Hello !

Unfortunately this has to be done manually. I don’t think that there is any other way to remove it without affecting the code.

Thank you !

Viewing 2 posts - 1 through 2 (of 2 total)
The forum ‘Newspaper’ is closed to new topics and replies.