How to filter content on Save/Publish to add rel=”nofollow” to all external links?

I would try “wp_insert_post_data” filter. add_filter(‘wp_insert_post_data’, ‘new_content’ ); function new_content($content) { preg_match_all(‘~<a.*>~isU’,$content[“post_content”],$matches); for ( $i = 0; $i <= sizeof($matches[0]); $i++){ if ( !preg_match( ‘~nofollow~is’,$matches[0][$i]) ){ $result = trim($matches[0][$i],”>”); $result .= ‘ rel=”nofollow”>’; $content[‘post_content’] = str_replace($matches[0][$i], $result, $content[‘post_content’]); } } return $content; } Obviously needs work, just a PoC.

First WordPress Plugin – Stat Issues

I’m having the same problem. Take a look at the opening comments of content-types-wordpress-plugin.php, it looks like there are extra line breaks between each line, which may disrupt the parser that pulls out the version number, etc. If you don’t see the extra breaks when you develop locally, you may have to play with the … Read more