0

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.

  • 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? – Andy Macaulay-Brook Apr 5 '18 at 11:38
2

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.

  • Thanks @kuchenundkakao apply_filters didn't work for some reason I have tried that before. But wpautop did! – BoyIsBadNews Apr 5 '18 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)) – kuchenundkakao Apr 5 '18 at 13:17

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service, privacy policy and cookie policy

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