0

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?

1 Answer 1

1

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.

1
  • Yor are always welcome. Commented Mar 25, 2012 at 2:53

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service and acknowledge you have read our privacy policy.

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