How to remove curly quotes from WordPress post

While doing the copy and paste from any website is always problem. While coping the code. curly quotes come and you want to convert that into straight quotes. Some time you want to remove curly quotes from WordPress post title or body.

How to remove curly quotes from WordPress post Title and body.

Here we have given following code which can be useful. The apostrophe should be straight not curly in WordPress.

Just Open your functions.php file from your theme folder. If you did not created functions.php file then you can paste this code in your header.php file.

remove_filter('comment_text', 'wptexturize');
remove_filter('the_title', 'wptexturize');
remove_filter('the_content', 'wptexturize');

This will solve your problem.

How to remove curly quotes and use straight quotes then use following code.

function removesmartquotes($content) {
$content = str_replace('“', '"', $content);
$content = str_replace('”', '"', $content);
$content = str_replace('‘', ''', $content);
$content = str_replace('’', ''', $content);

return $content;
}
add_filter('the_content', 'removesmartquotes');
add_filter('comment_text', 'removesmartquotes');

More reference

code snippets which is most useful in functions.php, wordpress

code snippets which is most useful in functions.php, wordpress

In wordpress – wp-includes/default-filters.php file, we have following list of filters which we can override.

/ Display filters
//add_filter('the_title', 'wptexturize');
add_filter('the_title', 'convert_chars');
add_filter('the_title', 'trim');
 
//add_filter('the_content', 'wptexturize');
add_filter('the_content', 'convert_smilies');
add_filter('the_content', 'convert_chars');
add_filter('the_content', 'wpautop');
add_filter('the_content', 'prepend_attachment');
 
//add_filter('the_excerpt', 'wptexturize');
add_filter('the_excerpt', 'convert_smilies');
add_filter('the_excerpt', 'convert_chars');
add_filter('the_excerpt', 'wpautop');
add_filter('get_the_excerpt', 'wp_trim_excerpt');
 
//add_filter('comment_text', 'wptexturize');
add_filter('comment_text', 'convert_chars');
add_filter('comment_text', 'make_clickable', 9);
add_filter('comment_text', 'force_balance_tags', 25);
add_filter('comment_text', 'convert_smilies', 20);
add_filter('comment_text', 'wpautop', 30);
 
add_filter('comment_excerpt', 'convert_chars');
 
//add_filter('list_cats', 'wptexturize');
//add_filter('single_post_title', 'wptexturize');

 

 

Add a Comment

Your email address will not be published. Required fields are marked *