1

I'm trying to get formating but with no luck. My code looks like this

global $post;
$content = $post->post_content;

And to output here

<div class="tribe-events-single-event-description tribe-events-content">'.$content.'</div>

Please if anyone have suggestions let me know.

1
  • is this in a theme? Is there any reason why you can't use the_content() as normal between your opening and closing div tags? Commented Apr 5, 2018 at 11:38

1 Answer 1

5

If i get your question correct, you want the post_content formatted like the content put out by the_content, right?

Change your upper code like this:

global $post;
$content = apply_filters('the_content',$post->post_content);

This does everything to your content that would be performed when outputting it by the_content();

If you only want the p and b tags, you can use wpautop($post->post_content) instead.

2
  • 1
    Thanks @kuchenundkakao apply_filters didn't work for some reason I have tried that before. But wpautop did! Commented Apr 5, 2018 at 13:14
  • Hm, weird... If you want to have shortcode execution also, you can change the code to wpautop(do_shortcodes($post->post_content)) Commented Apr 5, 2018 at 13:17

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.