The correct answer is
<textarea><?php echo esc_textarea($whatever); ?></textarea>
I answered an identical question earlier today HERE which tackled the same issue. In the case where you don't want to use a plugin like that suggested by EarnestoDev, you can simply wrap the output of your
<textarea></textarea> with PHP's
htmlspecialchars function like so;
<textarea name="my_html"> <?php echo htmlspecialchars($content); ?> </textarea>
Regardless of whether its a
textarea or an
input field etc, you still need to wrap your input in
htmlspecialchars to preserve your tags from being stripped.
Use the plugin I posted here: Problem with <code> tag .
Does what you need and more!
Yes, there must be. When you save this into a custom field with a key let's say "test"...
You will get Test1Test2 when you run...
echo get_post_meta($post->ID, 'test', true);
If I knew which filter was responsible for this I'd just do a remove_filter(). It would be great if there was a plugin that would show you what filters are registered to a specific hook. (There is a get_post_meta hook defined in /wp-includes/meta.php)