Yesterday one of my client ask me they want to show post contents formatted like they added in admin TinyMCE editor with new lines/break etc. We have only called post contents to show in frontend, but not formatted like in admin.
We can make use of wpautop() function which helps in this.
To use this, just wrap the content with this function.
So overall, it looks like below:
<?php echo wpautop(get_post_field('post_content', $post_id)); ?>
Simple isnt it? Try :)
No comments:
Post a Comment