I have a Custom Post Type that has several custom fields. One of the fields is multi-line and includes text with p tags.

When I view this field in the visual editor the p tags are all there.

I suspect the issue is how I am displaying the data in a custom template.

This is the code that I am using in the template to pull this particular custom field

 <?php $key="story"; echo get_post_meta($post->ID, $key, true); ?>

Is it the get_post_meta that is stripping these tags or something else? If it is this what should I be using instead?

Thanks for any clues

2 Answers
2

Add this to your functions.php file:

add_filter( 'meta_content', 'wptexturize' );
add_filter( 'meta_content', 'convert_smilies' );
add_filter( 'meta_content', 'convert_chars' );
add_filter( 'meta_content', 'wpautop' );
add_filter( 'meta_content', 'shortcode_unautop' );
add_filter( 'meta_content', 'prepend_attachment' );

Then use this code to pull in the result:

<?php $story_content = get_post_meta($post->ID, 'story', true); echo apply_filters('meta_content', $story_content); ?>

Leave a Reply

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