Skip to content

Instantly share code, notes, and snippets.

Embed
What would you like to do?
Fix curly quotes on post save and display
function rkv_no_curly_display () {
// call the global
global $post;
// get the post content
$content = $post->post_content;
// clean it up
$original = array('“', '”', '’');
$replaced = array('"', '"', '\'');
// now style and return it
return wpautop( str_replace($original, $replaced, $content) );
}
add_filter('the_content', 'rkv_no_curly_display', 10);
function rkv_no_curly_save( $content ) {
// call the global
global $post;
// get the content
$content = $post->post_content;
// clean it up
$original = array('“', '”', '’');
$replaced = array('"', '"', '\'');
// now style and return it
return str_replace($original, $replaced, $content);
}
add_action('content_save_pre', 'rkv_no_curly_save');
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment