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 am using wordpress get post meta to store the value of a custom field into a variable. In this particular instance, It is actually grabbing the post's parent's custom field due to the $post->post_parent Here is the code:

<?php $cast_members = get_post_meta($post->post_parent, 'cast_members', true); ?>
    <p><?php echo $cast_members; ?></p>
<?php endif; ?>

The custom field cast_members is a series of cast members, each in its own paragraph. For some reason wordpress is stripping out the paragraph tags and displaying all of the cast members in a continuous string. I need to retain those paragraph tags so each cast member is on its own line. Any idea why get_post_meta strips out tags and how to fix it?

share|improve this question
add comment

1 Answer

up vote 0 down vote accepted

Change above code to like this:

<?php $cast_members = get_post_meta($post->post_parent, 'cast_members', true); ?>
<p><?php echo wpautop($cast_members); ?></p>
<?php endif; ?>

in this code wpautop() function automatically adds p tag for cast members.

share|improve this answer
    
perfect, thanks! –  JCHASE11 Mar 24 '12 at 19:23
    
Yor are always welcome. –  Vinod Dalvi Mar 25 '12 at 2:53
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.