0

I'm new to PHP and WordPress.

I've created a site on WordPress, where the user can add an HTML code snippet (the inputs are taken using a metabox and displayed). The problem is WordPress doesn't render the input's value, rather it converts it to ASCII and displays the HTML code snippet as raw HTML rather than rendering it.

Is there any solution for this? In certain parts of the template I would like to display the rendered HTML, and also the escaped (raw) HTML.

Please note that I am using a custom metabox in a custom post type. I generated the metabox using this generator.

0

When you want to output trusted html, use html_entity_decode.

$orig = "I'll \"walk\" the <b>dog</b> now";

$a = htmlentities($orig);

$b = html_entity_decode($a);

echo $a; // I'll &quot;walk&quot; the &lt;b&gt;dog&lt;/b&gt; now

echo $b; // I'll "walk" the <b>dog</b> now

You can find more examples here.

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service, privacy policy and cookie policy

Not the answer you're looking for? Browse other questions tagged or ask your own question.