Take the 2-minute tour ×
WordPress Development Stack Exchange is a question and answer site for WordPress developers and administrators. It's 100% free, no registration required.

I have a problem with output text. When I editing text in the WordPress control panel everything looks normal:

http://i.stack.imgur.com/GaIut.png

but when I output it to the html:

<?php esc_html( wp_richedit_pre( $_product->details ) ); ?>

It looks like this:

http://i.stack.imgur.com/r81xE.png

What could be wrong? Please for help.

share|improve this question
add comment

2 Answers 2

Assuming that $_product->details contains what can be referred to as post content, and contains HTML, and you want to have that HTML rendered by the browser then you're doing it wrong.

Please refer to the esc_html function and play around with it in a sandbox - you will soon find out that what the function does (just like the Codex says) is it escapes the HTML, i.e. transforms any special symbols to HTML entities, so these symbols are rendered as symbols and are not interpreted by your browser.

echo esc_html('<b>a string</b>'); // Produces &lt;b&gt;a string&lt;/b&gt;
echo '<b>a string</b>'; // Produces <b>a string</b>

So the short answer to your problem appears to be - remove the esc_html function from around the output.

share|improve this answer
    
I tried in this way (remove the 'esc_html'), but nothing has changed. –  Siri Oct 19 '11 at 16:30
    
Can you paste a var_dump($_product->details); of your $_product->details here so that we can see what data is is contained there in the first place? –  soulseekah Oct 20 '11 at 6:15
add comment
up vote 0 down vote accepted

hmm ... strange. I looked to the file 'wp-includes/formatting.php' on the functions *wp_richedit_pre*:

function wp_richedit_pre($text) {
      // Filtering a blank results in an annoying <br />\n
      if ( empty($text) ) return apply_filters('richedit_pre', '');

      $output = convert_chars($text);
      $output = wpautop($output);
      $output = htmlspecialchars($output, ENT_NOQUOTES);

      return apply_filters('richedit_pre', $output);
}

Instead '*wp_richedit_pre()*' I used 'wpautop()' and it works.

http://i.stack.imgur.com/Jiuiy.png

Thanks for the hint Soulseekah.

share|improve this answer
add comment

Your Answer

 
discard

By posting your answer, you agree to the privacy policy and terms of service.

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