Samir Karmacharya February 2016

How can i get inverted coma instead of apostrophe in wordpress content frontend

I write inverted comma on admin tinymce editor but on frontend it displays an apostrophe when I use:

the_content();

But when I use

echo get_the_content();

it will display inverted comma.

And when I use

$content=get_the_content();
$content=apply_filters( 'the_content', $content );
echo $content = str_replace(']]>', ']]>', $content);

it again display apostrophe instead of inverted comma.

I try to replace apostrophe by comma using

str_replace("’", "'", $content);

It doesn't work. Any suggestions?

Answers


Samir Karmacharya February 2016

I have tried this one

<?php $content = get_the_content();
    $content = apply_filters( 'the_content', $content );
    $content = str_replace(']]>', ']]&gt;', $content);
    $content = html_entity_decode($content);//added extra code
    echo $content = str_replace("’", "'", $content);
?>

adding

$content = html_entity_decode($content);

this code then it works for me. But still didn't know why WordPress convert.

Post Status

Asked in February 2016
Viewed 1,466 times
Voted 4
Answered 1 times

Search




Leave an answer