• Resolved rjpinney

    (@rjpinney)


    I’m using some custom text fields but the formatting (line/para breaks – itals seem fine) are being stripped out on the front end.

    The code I’m using to pull the field is as follows:

    <?php echo get_post_meta($post->ID, 'author_bio', true); ?>

    I’m not sure if it’s a problem with the code or something else; can anyone recommend a way of showing the content of the custom field WITH its formatting?

    Thanks

Viewing 4 replies - 1 through 4 (of 4 total)
  • I’m pretty sure all formatting is stripped from custom fields by default. Perhaps you need to consider another approach?

    Thread Starter rjpinney

    (@rjpinney)

    I’m using the advanced custom fields plugin, which provides a full text editor – if I set the style to ‘heading 6’ for example, it will render line breaks.

    I saw somewhere a very brief comment on a similar issue which said that if you use the get_post_meta command, it will strip out formatting, but that there was an alternative way of retrieving the info that might also reflect the formatting?

    I’m using the advanced custom fields plugin

    Then I suggest that you post in that plugin’s dedicated forum via its page in the Plugin Repository.

    Thread Starter rjpinney

    (@rjpinney)

    Solved!

    Should anyone else run into this:

    Instead of using:

    <?php echo get_post_meta($post->ID, ‘YOURFIELDNAME’, true); ?>

    Use this:

    <?php the_field(‘YOURFIELDNAME’); ?>

    That seems to carry over the formatting.

Viewing 4 replies - 1 through 4 (of 4 total)
  • The topic ‘Get post meta WITH formatting?’ is closed to new replies.