Forum Replies Created

Viewing 1 replies (of 1 total)
  • I’m not sure if this will strip all MS Word code out, but I’ve been using this custom function successfully on a project.

    Pass $post->post_content to this function:

    function strip_msword_tags($content){
    
    	// Strip <span></span> tags
    	$content = preg_replace('/<span.*?>/', '', $content);
    	$content = str_replace('</span>', '', $content);
    
    	// Turn <div><br /></div> into </p><p>
    	$content = str_replace('<div><br /></div>', '</p><p>', $content);
    
    	// Strip <div></div> tags
    	$content = str_replace('<div>', '', $content);
    	$content = str_replace('</div>', '', $content);
    
    	// Apply WP filters
    	$content = apply_filters('the_content', $content);
    
    	return $content;
    }

    Hope that helps someone.

Viewing 1 replies (of 1 total)